Skip to content

Instantly share code, notes, and snippets.

@xeroc
Created August 7, 2018 15:16
Show Gist options
  • Save xeroc/36798ca15bc5593eee6d374885b62475 to your computer and use it in GitHub Desktop.
Save xeroc/36798ca15bc5593eee6d374885b62475 to your computer and use it in GitHub Desktop.
from peerplaysbase import operations
from peerplays import PeerPlays
from peerplays.account import Account
from peerplays.asset import Asset
from peerplaysbase import asset_permissions
from getpass import getpass
# The name of the issuer account
issuer = "nathan"
symbol = "BTC"
issue_to = {
"nathan": 500000,
}
# Instantiate PeerPlays (the master python class)
ppy = PeerPlays()
# Get full account details for issuer
account = Account(issuer, peerplays_instance=ppy)
# Get full asset details
asset = Asset(symbol, peerplays_instance=ppy)
# Unlock the wallet (asks for password)
ppy.wallet.unlock(getpass("Wallet passphrase: "))
# Create the operations that creates the asset
ops = list()
for to_name, amount in issue_to.items():
# Get receiver account details
to = Account(to_name, peerplays_instance=ppy)
# append operation
ops.append(operations.Asset_issue(**{
"fee": {"amount": 0, "asset_id": "1.3.0"}, # Will be filled in automatically
"issuer": account["id"], # the Issuer account
"asset_to_issue": {
"amount": int(amount * 10 ** asset["precision"]),
"asset_id": asset["id"]
},
"issue_to_account": to["id"],
"extensions": []
}))
# Finalize (bunle into transaction + serialize + sign) the operation with
# issuer key (needs to be added to the wallet first, e.g. using command line
# tool:
#
# $ peerplays addkey
#
print(ppy.finalizeOp(ops, account, "active"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment