Transactions and Accounts

Commit

The Commit class contains helper methods for posting, voting, transferring funds, updating witnesses and more. You don’t have to use this class directly, all of its methods are accessible trough main Steem class.

# accessing commit methods trough Steem
s = Steem()
s.commit.transfer(...)

# is same as
c = Commit(steem=Steem())
c.transfer(..)
class steem.steem.Commit(steemd_instance=None, no_broadcast=False, **kwargs)

Commit things to the Steem network.

This class contains helper methods to construct, sign and broadcast common transactions, such as posting, voting, sending funds, etc.

Parameters:
  • steemd (Steemd) – Steemd node to connect to*
  • offline (bool) – Do not broadcast transactions! (optional)
  • debug (bool) – Enable Debugging (optional)
  • keys (list,dict,string) – Predefine the wif keys to shortcut the wallet database

Three wallet operation modes are possible:

  • Wallet Database: Here, the steemlibs load the keys from the locally stored wallet SQLite database (see storage.py). To use this mode, simply call Steem() without the keys parameter
  • Providing Keys: Here, you can provide the keys for your accounts manually. All you need to do is add the wif keys for the accounts you want to use as a simple array using the keys parameter to Steem().
  • Force keys: This more is for advanced users and requires that you know what you are doing. Here, the keys parameter is a dictionary that overwrite the active, owner, posting or memo keys for any account. This mode is only used for foreign signatures!
allow(foreign, weight=None, permission='posting', account=None, threshold=None)

Give additional access to an account by some other public key or account.

Parameters:
  • foreign (str) – The foreign account that will obtain access
  • weight (int) – (optional) The weight to use. If not define, the threshold will be used. If the weight is smaller than the threshold, additional signatures will be required. (defaults to threshold)
  • permission (str) – (optional) The actual permission to modify (defaults to posting)
  • account (str) – (optional) the account to allow access to (defaults to default_account)
  • threshold (int) – The threshold that needs to be reached by signatures to be able to interact
approve_witness(witness, account=None, approve=True)

Vote for a witness. This method adds a witness to your set of approved witnesses. To remove witnesses see disapprove_witness.

Parameters:
  • witness (str) – witness to approve
  • account (str) – (optional) the account to allow access to (defaults to default_account)
broadcast(signed_trx)

Broadcast a transaction to the Steem network

Parameters:signed_trx (tx) – Signed transaction to broadcast
claim_reward_balance(reward_steem='0 STEEM', reward_sbd='0 SBD', reward_vests='0 VESTS', account=None)

Claim reward balances.

By default, this will claim all outstanding balances. To bypass this behaviour, set desired claim amount by setting any of reward_steem, reward_sbd or reward_vests.

Parameters:
  • reward_steem (string) – Amount of STEEM you would like to claim.
  • reward_sbd (string) – Amount of SBD you would like to claim.
  • reward_vests (string) – Amount of VESTS you would like to claim.
  • account (string) – The source account for the claim if not default_account is used.
comment_options(identifier, options, account=None)

Set the comment options

Parameters:
  • identifier (str) – Post identifier
  • options (dict) – The options to define.
  • account (str) – (optional) the account to allow access to (defaults to default_account)

For the options, you have these defaults::

{
    "author": "",
    "permlink": "",
    "max_accepted_payout": "1000000.000 SBD",
    "percent_steem_dollars": 10000,
    "allow_votes": True,
    "allow_curation_rewards": True,
}
convert(amount, account=None, request_id=None)

Convert SteemDollars to Steem (takes one week to settle)

Parameters:
  • amount (float) – number of VESTS to withdraw over a period of 104 weeks
  • account (str) – (optional) the source account for the transfer if not default_account
  • request_id (str) – (optional) identifier for tracking the conversion`
create_account(account_name, json_meta=None, password=None, owner_key=None, active_key=None, posting_key=None, memo_key=None, additional_owner_keys=[], additional_active_keys=[], additional_posting_keys=[], additional_owner_accounts=[], additional_active_accounts=[], additional_posting_accounts=[], store_keys=True, store_owner_key=False, delegation_fee_steem='0 STEEM', creator=None)

Create new account in Steem

The brainkey/password can be used to recover all generated keys (see steembase.account for more details.

By default, this call will use default_account to register a new name account_name with all keys being derived from a new brain key that will be returned. The corresponding keys will automatically be installed in the wallet.

Note

Account creations cost a fee that is defined by the network. If you create an account, you will need to pay for that fee!

You can partially pay that fee by delegating VESTS.

To pay the fee in full in STEEM, leave delegation_fee_steem set to 0 STEEM (Default).

To pay the fee partially in STEEM, partially with delegated VESTS, set delegation_fee_steem to a value greater than 1 STEEM. Required VESTS will be calculated automatically.

To pay the fee with maximum amount of delegation, set delegation_fee_steem to 1 STEEM. Required VESTS will be calculated automatically.

Warning

Don’t call this method unless you know what you are doing! Be sure to understand what this method does and where to find the private keys for your account.

Note

Please note that this imports private keys (if password is present) into the wallet by default. However, it does not import the owner key unless store_owner_key is set to True (default False). Do NOT expect to be able to recover it from the wallet if you lose your password!

Parameters:
  • account_name (str) – (required) new account name
  • json_meta (str) – Optional meta data for the account
  • owner_key (str) – Main owner key
  • active_key (str) – Main active key
  • posting_key (str) – Main posting key
  • memo_key (str) – Main memo_key
  • password (str) – Alternatively to providing keys, one can provide a password from which the keys will be derived
  • additional_owner_keys (list) – Additional owner public keys
  • additional_active_keys (list) – Additional active public keys
  • additional_posting_keys (list) – Additional posting public keys
  • additional_owner_accounts (list) – Additional owner account names
  • additional_active_accounts (list) – Additional active account names
  • additional_posting_accounts (list) – Additional posting account names
  • store_keys (bool) – Store new keys in the wallet (default: True)
  • store_owner_key (bool) – Store owner key in the wallet (default: False)
  • delegation_fee_steem (str) – (Optional) If set, creator pay a fee of this amount, and delegate the rest with VESTS (calculated automatically). Minimum: 1 STEEM. If left to 0 (Default), full fee is paid without VESTS delegation.
  • creator (str) – which account should pay the registration fee (defaults to default_account)
Raises:

AccountExistsException – if the account already exists on the blockchain

custom_json(id, json, required_auths=[], required_posting_auths=[])

Create a custom json operation

Parameters:
  • id (str) – identifier for the custom json (max length 32 bytes)
  • json (json) – the json data to put into the custom_json operation
  • required_auths (list) – (optional) required auths
  • required_posting_auths (list) – (optional) posting auths
decode_memo(enc_memo)

Try to decode an encrypted memo

delegate_vesting_shares(to_account: str, vesting_shares: str, account=None)

Delegate SP to another account.

Parameters:
  • to_account (string) – Account we are delegating shares to (delegatee).
  • vesting_shares (string) – Amount of VESTS to delegate eg. 10000 VESTS.
  • account (string) – The source account (delegator). If not specified, default_account is used.
disallow(foreign, permission='posting', account=None, threshold=None)

Remove additional access to an account by some other public key or account.

Parameters:
  • foreign (str) – The foreign account that will obtain access
  • permission (str) – (optional) The actual permission to modify (defaults to posting)
  • account (str) – (optional) the account to allow access to (defaults to default_account)
  • threshold (int) – The threshold that needs to be reached by signatures to be able to interact
disapprove_witness(witness, account=None)

Remove vote for a witness. This method removes a witness from your set of approved witnesses. To add witnesses see approve_witness.

Parameters:
  • witness (str) – witness to approve
  • account (str) – (optional) the account to allow access to (defaults to default_account)
finalizeOp(ops, account, permission)

This method obtains the required private keys if present in the wallet, finalizes the transaction, signs it and broadacasts it

Parameters:
  • ops (operation) – The operation (or list of operaions) to broadcast
  • account (operation) – The account that authorizes the operation
  • permission (string) – The required permission for signing (active, owner, posting)

... note:

If ``ops`` is a list of operation, they all need to be
signable by the same key! Thus, you cannot combine ops
that require active permission with ops that require
posting permission. Neither can you use different
accounts for different operations!
follow(follow, what=['blog'], account=None)

Follow another account’s blog

Parameters:
  • follow (str) – Follow this account
  • what (list) – List of states to follow (defaults to ['blog'])
  • account (str) – (optional) the account to allow access to (defaults to default_account)
interest(account)

Caluclate interest for an account

Parameters:account (str) – Account name to get interest for
post(title, body, author, permlink=None, reply_identifier=None, json_metadata=None, comment_options=None, community=None, tags=None, beneficiaries=None, self_vote=False)

Create a new post.

If this post is intended as a reply/comment, reply_identifier needs to be set with the identifier of the parent post/comment (eg. @author/permlink).

Optionally you can also set json_metadata, comment_options and upvote the newly created post as an author.

Setting category, tags or community will override the values provided in json_metadata and/or comment_options where appropriate.

Parameters:
  • title (str) – Title of the post
  • body (str) – Body of the post/comment
  • author (str) – Account are you posting from
  • permlink (str) – Manually set the permlink (defaults to None). If left empty, it will be derived from title automatically.
  • reply_identifier (str) – Identifier of the parent post/comment (only if this post is a reply/comment).
  • json_metadata (str, dict) – JSON meta object that can be attached to the post.
  • comment_options (str, dict) –

    JSON options object that can be attached to the post. Example:

    comment_options = {
        'max_accepted_payout': '1000000.000 SBD',
        'percent_steem_dollars': 10000,
        'allow_votes': True,
        'allow_curation_rewards': True,
        'extensions': [[0, {
            'beneficiaries': [
                {'account': 'account1', 'weight': 5000},
                {'account': 'account2', 'weight': 5000},
            ]}
        ]]
    }
    
  • community (str) – (Optional) Name of the community we are posting into. This will also override the community specified in json_metadata.
  • tags (str, list) – (Optional) A list of tags (5 max) to go with the post. This will also override the tags specified in json_metadata. The first tag will be used as a ‘category’. If provided as a string, it should be space separated.
  • beneficiaries (list of dicts) –

    (Optional) A list of beneficiaries for posting reward distribution. This argument overrides beneficiaries as specified in comment_options.

    For example, if we would like to split rewards between account1 and account2:

    beneficiaries = [
        {'account': 'account1', 'weight': 5000},
        {'account': 'account2', 'weight': 5000}
    ]
    
  • self_vote (bool) – (Optional) Upvote the post as author, right after posting.
resteem(identifier, account=None)

Resteem a post

Parameters:
  • identifier (str) – post identifier (@<account>/<permlink>)
  • account (str) – (optional) the account to allow access to (defaults to default_account)
set_withdraw_vesting_route(to, percentage=100, account=None, auto_vest=False)

Set up a vesting withdraw route. When vesting shares are withdrawn, they will be routed to these accounts based on the specified weights.

Parameters:
  • to (str) – Recipient of the vesting withdrawal
  • percentage (float) – The percent of the withdraw to go to the ‘to’ account.
  • account (str) – (optional) the vesting account
  • auto_vest (bool) – Set to true if the from account should receive the VESTS as VESTS, or false if it should receive them as STEEM. (defaults to False)
sign(unsigned_trx, wifs=[])

Sign a provided transaction witht he provided key(s)

Parameters:
  • unsigned_trx (dict) – The transaction to be signed and returned
  • wifs (string) – One or many wif keys to use for signing a transaction. If not present, the keys will be loaded from the wallet as defined in “missing_signatures” key of the transactizions.
transfer(to, amount, asset, memo='', account=None)

Transfer SBD or STEEM to another account.

Parameters:
  • to (str) – Recipient
  • amount (float) – Amount to transfer
  • asset (str) – Asset to transfer (SBD or STEEM)
  • memo (str) – (optional) Memo, may begin with # for encrypted messaging
  • account (str) – (optional) the source account for the transfer if not default_account
transfer_from_savings(amount, asset, memo, request_id=None, to=None, account=None)

Withdraw SBD or STEEM from ‘savings’ account.

Parameters:
  • amount (float) – STEEM or SBD amount
  • asset (float) – ‘STEEM’ or ‘SBD’
  • memo (str) – (optional) Memo
  • request_id (str) – (optional) identifier for tracking or cancelling the withdrawal
  • to (str) – (optional) the source account for the transfer if not default_account
  • account (str) – (optional) the source account for the transfer if not default_account
transfer_from_savings_cancel(request_id, account=None)

Cancel a withdrawal from ‘savings’ account.

Parameters:
  • request_id (str) – Identifier for tracking or cancelling the withdrawal
  • account (str) – (optional) the source account for the transfer if not default_account
transfer_to_savings(amount, asset, memo, to=None, account=None)

Transfer SBD or STEEM into a ‘savings’ account.

Parameters:
  • amount (float) – STEEM or SBD amount
  • asset (float) – ‘STEEM’ or ‘SBD’
  • memo (str) – (optional) Memo
  • to (str) – (optional) the source account for the transfer if not default_account
  • account (str) – (optional) the source account for the transfer if not default_account
transfer_to_vesting(amount, to=None, account=None)

Vest STEEM

Parameters:
  • amount (float) – number of STEEM to vest
  • to (str) – (optional) the source account for the transfer if not default_account
  • account (str) – (optional) the source account for the transfer if not default_account
unfollow(unfollow, what=['blog'], account=None)

Unfollow another account’s blog

Parameters:
  • unfollow (str) – Follow this account
  • what (list) – List of states to follow (defaults to ['blog'])
  • account (str) – (optional) the account to allow access to (defaults to default_account)
update_account_profile(profile, account=None)

Update an account’s meta data (json_meta)

Parameters:
  • json (dict) – The meta data to use (i.e. use Profile() from account.py)
  • account (str) – (optional) the account to allow access to (defaults to default_account)
update_memo_key(key, account=None)

Update an account’s memo public key

This method does not add any private keys to your wallet but merely changes the memo public key.

Parameters:
  • key (str) – New memo public key
  • account (str) – (optional) the account to allow access to (defaults to default_account)
vote(identifier, weight, account=None)

Vote for a post

Parameters:
  • identifier (str) – Identifier for the post to upvote Takes the form @author/permlink
  • weight (float) – Voting weight. Range: -100.0 - +100.0. May not be 0.0
  • account (str) – Voter to use for voting. (Optional)

If voter is not defines, the default_account will be taken or a ValueError will be raised

steempy set default_account <account>
withdraw_vesting(amount, account=None)

Withdraw VESTS from the vesting account.

Parameters:
  • amount (float) – number of VESTS to withdraw over a period of 104 weeks
  • account (str) – (optional) the source account for the transfer if not default_account
witness_feed_publish(steem_usd_price, quote='1.000', account=None)

Publish a feed price as a witness.

Parameters:
  • steem_usd_price (float) – Price of STEEM in USD (implied price)
  • quote (float) – (optional) Quote Price. Should be 1.000, unless we are adjusting the feed to support the peg.
  • account (str) – (optional) the source account for the transfer if not default_account
witness_update(signing_key, url, props, account=None)

Update witness

Parameters:
  • signing_key (pubkey) – Signing key
  • url (str) – URL
  • props (dict) – Properties
  • account (str) –

    (optional) witness account name

    Properties::

    {
        "account_creation_fee": x,
        "maximum_block_size": x,
        "sbd_interest_rate": x,
    }
    

TransactionBuilder

class steem.transactionbuilder.TransactionBuilder(tx=None, steemd_instance=None, wallet_instance=None, no_broadcast=False, expiration=60)

This class simplifies the creation of transactions by adding operations and signers.

addSigningInformation(account, permission)

This is a private method that adds side information to a unsigned/partial transaction in order to simplify later signing (e.g. for multisig or coldstorage)

broadcast()

Broadcast a transaction to the Steem network

Parameters:tx (tx) – Signed transaction to broadcast
sign()

Sign a provided transaction witht he provided key(s)

Parameters:
  • tx (dict) – The transaction to be signed and returned
  • wifs (string) – One or many wif keys to use for signing a transaction. If not present, the keys will be loaded from the wallet as defined in “missing_signatures” key of the transactions.

Wallet

Wallet is a low-level utility. It could be used to create 3rd party cli and GUI wallets on top of steem-python‘s infrastructure.

class steem.wallet.Wallet(steemd_instance=None, **kwargs)

The wallet is meant to maintain access to private keys for your accounts. It either uses manually provided private keys or uses a SQLite database managed by storage.py.

Parameters:
  • rpc (Steem) – RPC connection to a Steem node
  • keys (array,dict,string) – Predefine the wif keys to shortcut the wallet database

Three wallet operation modes are possible:

  • Wallet Database: Here, steemlibs loads the keys from the locally stored wallet SQLite database (see storage.py). To use this mode, simply call Steem() without the keys parameter
  • Providing Keys: Here, you can provide the keys for your accounts manually. All you need to do is add the wif keys for the accounts you want to use as a simple array using the keys parameter to Steem().
  • Force keys: This more is for advanced users and requires that you know what you are doing. Here, the keys parameter is a dictionary that overwrite the active, owner, posting or memo keys for any account. This mode is only used for foreign signatures!
addPrivateKey(wif)

Add a private key to the wallet database

changePassphrase()

Change the passphrase for the wallet database

created()

Do we have a wallet database already?

decrypt_wif(encwif)

decrypt a wif key

encrypt_wif(wif)

Encrypt a wif key

getAccount(pub)

Get the account data for a public key

getAccountFromPrivateKey(wif)

Obtain account name from private key

getAccountFromPublicKey(pub)

Obtain account name from public key

getAccounts()

Return all accounts installed in the wallet database

getAccountsWithPermissions()

Return a dictionary for all installed accounts with their corresponding installed permissions

getActiveKeyForAccount(name)

Obtain owner Active Key for an account from the wallet database

getKeyType(account, pub)

Get key type

getMemoKeyForAccount(name)

Obtain owner Memo Key for an account from the wallet database

getOwnerKeyForAccount(name)

Obtain owner Private Key for an account from the wallet database

getPassword(confirm=False, text='Passphrase: ')

Obtain a password from the user

getPostingKeyForAccount(name)

Obtain owner Posting Key for an account from the wallet database

getPrivateKeyForPublicKey(pub)

Obtain the private key for a given public key

Parameters:pub (str) – Public Key
getPublicKeys()

Return all installed public keys

lock()

Lock the wallet database

locked()

Is the wallet database locked?

newWallet()

Create a new wallet database

removeAccount(account)

Remove all keys associated with a given account

removePrivateKeyFromPublicKey(pub)

Remove a key from the wallet database

setKeys(loadkeys)

This method is strictly only for in memory keys that are passed to Wallet/Steem with the keys argument

unlock(pwd=None)

Unlock the wallet database