beem.steem

class beem.steem.Steem(node='', rpcuser=None, rpcpassword=None, debug=False, data_refresh_time_seconds=900, **kwargs)

Bases: beem.blockchaininstance.BlockChainInstance

Connect to the Steem network.

Parameters:
  • node (str) – Node to connect to (optional)
  • rpcuser (str) – RPC user (optional)
  • rpcpassword (str) – RPC password (optional)
  • nobroadcast (bool) – Do not broadcast a transaction! (optional)
  • unsigned (bool) – Do not sign a transaction! (optional)
  • debug (bool) – Enable Debugging (optional)
  • keys (array, dict, string) – Predefine the wif keys to shortcut the wallet database (optional)
  • wif (array, dict, string) – Predefine the wif keys to shortcut the wallet database (optional)
  • offline (bool) – Boolean to prevent connecting to network (defaults to False) (optional)
  • expiration (int) – Delay in seconds until transactions are supposed to expire (optional) (default is 30)
  • blocking (str) – Wait for broadcasted transactions to be included in a block and return full transaction (can be “head” or “irreversible”)
  • bundle (bool) – Do not broadcast transactions right away, but allow to bundle operations. It is not possible to send out more than one vote operation and more than one comment operation in a single broadcast (optional)
  • appbase (bool) – Use the new appbase rpc protocol on nodes with version 0.19.4 or higher. The settings has no effect on nodes with version of 0.19.3 or lower.
  • num_retries (int) – Set the maximum number of reconnects to the nodes before NumRetriesReached is raised. Disabled for -1. (default is -1)
  • num_retries_call (int) – Repeat num_retries_call times a rpc call on node error (default is 5)
  • timeout (int) – Timeout setting for https nodes (default is 60)
  • use_sc2 (bool) – When True, a steemconnect object is created. Can be used for broadcast posting op or creating hot_links (default is False)
  • steemconnect (SteemConnect) – A SteemConnect object can be set manually, set use_sc2 to True
  • custom_chains (dict) – custom chain which should be added to the known chains

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!

If no node is provided, it will connect to default nodes of http://geo.steem.pl. Default settings can be changed with:

steem = Steem(<host>)

where <host> starts with https://, ws:// or wss://.

The purpose of this class it to simplify interaction with Steem.

The idea is to have a class that allows to do this:

>>> from beem import Steem
>>> steem = Steem()
>>> print(steem.get_blockchain_version())  

This class also deals with edits, votes and reading content.

Example for adding a custom chain:

from beem import Steem
stm = Steem(node=["https://mytstnet.com"], custom_chains={"MYTESTNET":
    {'chain_assets': [{'asset': 'SBD', 'id': 0, 'precision': 3, 'symbol': 'SBD'},
                      {'asset': 'STEEM', 'id': 1, 'precision': 3, 'symbol': 'STEEM'},
                      {'asset': 'VESTS', 'id': 2, 'precision': 6, 'symbol': 'VESTS'}],
     'chain_id': '79276aea5d4877d9a25892eaa01b0adf019d3e5cb12a97478df3298ccdd01674',
     'min_version': '0.0.0',
     'prefix': 'MTN'}
    }
)
chain_params
get_network(use_stored_data=True, config=None)

Identify the network

Parameters:use_stored_data (bool) – if True, stored data will be returned. If stored data are empty or old, refresh_data() is used.
Returns:Network parameters
Return type:dictionary
get_sbd_per_rshares(not_broadcasted_vote_rshares=0, use_stored_data=True)

Returns the current rshares to SBD ratio

get_steem_per_mvest(time_stamp=None, use_stored_data=True)

Returns the MVEST to STEEM ratio

Parameters:time_stamp (int) – (optional) if set, return an estimated STEEM per MVEST ratio for the given time stamp. If unset the current ratio is returned (default). (can also be a datetime object)
get_token_per_mvest(time_stamp=None, use_stored_data=True)

Returns the MVEST to TOKEN ratio

Parameters:time_stamp (int) – (optional) if set, return an estimated TOKEN per MVEST ratio for the given time stamp. If unset the current ratio is returned (default). (can also be a datetime object)
hardfork
is_steem
rshares_to_sbd(rshares, not_broadcasted_vote=False, use_stored_data=True)

Calculates the current SBD value of a vote

rshares_to_token_backed_dollar(rshares, not_broadcasted_vote=False, use_stored_data=True)

Calculates the current HBD value of a vote

rshares_to_vote_pct(rshares, post_rshares=0, steem_power=None, vests=None, voting_power=10000, use_stored_data=True)

Obtain the voting percentage for a desired rshares value for a given Steem Power or vesting shares and voting_power Give either steem_power or vests, not both. When the output is greater than 10000 or less than -10000, the given absolute rshares are too high

Returns the required voting percentage (100% = 10000)

Parameters:
  • rshares (number) – desired rshares value
  • steem_power (number) – Steem Power
  • vests (number) – vesting shares
  • voting_power (int) – voting power (100% = 10000)
sbd_symbol

get the current chains symbol for SBD (e.g. “TBD” on testnet)

sbd_to_rshares(sbd, not_broadcasted_vote=False, use_stored_data=True)

Obtain the r-shares from SBD

Parameters:
  • sbd (str, int, amount.Amount) – SBD
  • not_broadcasted_vote (bool) – not_broadcasted or already broadcasted vote (True = not_broadcasted vote). Only impactful for very high amounts of SBD. Slight modification to the value calculation, as the not_broadcasted vote rshares decreases the reward pool.
sbd_to_vote_pct(sbd, post_rshares=0, steem_power=None, vests=None, voting_power=10000, not_broadcasted_vote=True, use_stored_data=True)

Obtain the voting percentage for a desired SBD value for a given Steem Power or vesting shares and voting power Give either Steem Power or vests, not both. When the output is greater than 10000 or smaller than -10000, the SBD value is too high.

Returns the required voting percentage (100% = 10000)

Parameters:
  • sbd (str, int, amount.Amount) – desired SBD value
  • steem_power (number) – Steem Power
  • vests (number) – vesting shares
  • not_broadcasted_vote (bool) – not_broadcasted or already broadcasted vote (True = not_broadcasted vote). Only impactful for very high amounts of SBD. Slight modification to the value calculation, as the not_broadcasted vote rshares decreases the reward pool.
sp_to_rshares(steem_power, post_rshares=0, voting_power=10000, vote_pct=10000, use_stored_data=True)

Obtain the r-shares from Steem power

Parameters:
  • steem_power (number) – Steem Power
  • post_rshares (int) – rshares of post which is voted
  • voting_power (int) – voting power (100% = 10000)
  • vote_pct (int) – voting percentage (100% = 10000)
sp_to_sbd(sp, post_rshares=0, voting_power=10000, vote_pct=10000, not_broadcasted_vote=True, use_stored_data=True)

Obtain the resulting SBD vote value from Steem power

Parameters:
  • steem_power (number) – Steem Power
  • post_rshares (int) – rshares of post which is voted
  • voting_power (int) – voting power (100% = 10000)
  • vote_pct (int) – voting percentage (100% = 10000)
  • not_broadcasted_vote (bool) – not_broadcasted or already broadcasted vote (True = not_broadcasted vote).

Only impactful for very big votes. Slight modification to the value calculation, as the not_broadcasted vote rshares decreases the reward pool.

sp_to_vests(sp, timestamp=None, use_stored_data=True)

Converts SP to vests

Parameters:
  • sp (float) – Steem power to convert
  • timestamp (datetime) – (Optional) Can be used to calculate the conversion rate from the past
steem_symbol

get the current chains symbol for STEEM (e.g. “TESTS” on testnet)

token_power_to_token_backed_dollar(token_power, post_rshares=0, voting_power=10000, vote_pct=10000, not_broadcasted_vote=True, use_stored_data=True)

Obtain the resulting Token backed dollar vote value from Token power

Parameters:
  • hive_power (number) – Token Power
  • post_rshares (int) – rshares of post which is voted
  • voting_power (int) – voting power (100% = 10000)
  • vote_pct (int) – voting percentage (100% = 10000)
  • not_broadcasted_vote (bool) – not_broadcasted or already broadcasted vote (True = not_broadcasted vote).

Only impactful for very big votes. Slight modification to the value calculation, as the not_broadcasted vote rshares decreases the reward pool.

token_power_to_vests(token_power, timestamp=None, use_stored_data=True)

Converts TokenPower to vests

Parameters:
  • token_power (float) – Token power to convert
  • timestamp (datetime) – (Optional) Can be used to calculate the conversion rate from the past
vests_symbol

get the current chains symbol for VESTS

vests_to_rshares(vests, post_rshares=0, voting_power=10000, vote_pct=10000, subtract_dust_threshold=True, use_stored_data=True)

Obtain the r-shares from vests

Parameters:
  • vests (number) – vesting shares
  • post_rshares (int) – rshares of post which is voted
  • voting_power (int) – voting power (100% = 10000)
  • vote_pct (int) – voting percentage (100% = 10000)
vests_to_sbd(vests, post_rshares=0, voting_power=10000, vote_pct=10000, not_broadcasted_vote=True, use_stored_data=True)

Obtain the resulting SBD vote value from vests

Parameters:
  • vests (number) – vesting shares
  • post_rshares (int) – rshares of post which is voted
  • voting_power (int) – voting power (100% = 10000)
  • vote_pct (int) – voting percentage (100% = 10000)
  • not_broadcasted_vote (bool) – not_broadcasted or already broadcasted vote (True = not_broadcasted vote).

Only impactful for very big votes. Slight modification to the value calculation, as the not_broadcasted vote rshares decreases the reward pool.

vests_to_sp(vests, timestamp=None, use_stored_data=True)

Converts vests to SP

Parameters:
  • vests/float vests (amount.Amount) – Vests to convert
  • timestamp (int) – (Optional) Can be used to calculate the conversion rate from the past
vests_to_token_power(vests, timestamp=None, use_stored_data=True)

Converts vests to TokenPower

Parameters:
  • vests/float vests (amount.Amount) – Vests to convert
  • timestamp (int) – (Optional) Can be used to calculate the conversion rate from the past