beem.steem module¶
-
class
beem.steem.
Steem
(node='', rpcuser='', rpcpassword='', debug=False, data_refresh_time_seconds=900, **kwargs)¶ Bases:
object
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)
- debug (bool) – Enable Debugging (optional)
- keys (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) - proposer (str) – Propose a transaction using this proposer (optional)
- proposal_expiration (int) – Expiration time (in seconds) for the proposal (optional)
- proposal_review (int) – Review period (in seconds) for the proposal (optional)
- expiration (int) – Delay in seconds until transactions are supposed to expire (optional)
- blocking (str) – Wait for broadcasted transactions to be included in a block and return full transaction (can be “head” or “irrversible”)
- bundle (bool) – Do not broadcast transactions right away, but allow to bundle operations (optional)
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 callSteem()
without thekeys
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 toSteem()
. - 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 theactive
,owner
, ormemo
keys for any account. This mode is only used for foreign signatures!
If no node is provided, it will connect to the node of http://uptick.rocks. It is highly recommended that you pick your own node instead. Default settings can be changed with:
uptick set node <host>
where
<host>
starts withws://
orwss://
.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.info())
All that is requires is for the user to have added a key with
uptick
uptick addkey
and setting a default author:
uptick set default_account xeroc
This class also deals with edits, votes and reading content.
-
allow
(foreign, weight=None, permission='posting', account=None, threshold=None, **kwargs)¶ 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
active
) - 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
-
broadcast
(tx=None)¶ Broadcast a transaction to the Steem network
Parameters: tx (tx) – Signed transaction to broadcast
-
chain_params
¶
-
clear
()¶
-
connect
(node='', rpcuser='', rpcpassword='', **kwargs)¶ Connect to Steem network (internal use only)
-
create_account
(account_name, creator=None, owner_key=None, active_key=None, memo_key=None, posting_key=None, password=None, additional_owner_keys=[], additional_active_keys=[], additional_posting_keys=[], additional_owner_accounts=[], additional_active_accounts=[], additional_posting_accounts=[], storekeys=True, store_owner_key=False, **kwargs)¶ Create new account on Steem
The brainkey/password can be used to recover all generated keys (see beembase.account for more details.
By default, this call will use
default_account
to register a new nameaccount_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.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 for security reasons. 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
- registrar (str) – which account should pay the registration fee
(defaults to
default_account
) - owner_key (str) – Main owner key
- active_key (str) – Main active 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 (array) – Additional owner public keys
- additional_active_keys (array) – Additional active public keys
- additional_owner_accounts (array) – Additional owner account names
- additional_active_accounts (array) – Additional acctive account names
- storekeys (bool) – Store new keys in the wallet (default:
True
)
Raises: AccountExistsException – if the account already exists on the blockchain
-
custom_json
(id, json_data, required_auths=[], required_posting_auths=[])¶ Create a custom json operation :param str id: identifier for the custom json (max length 32 bytes) :param json json_data: the json data to put into the custom_json
operationParameters: - required_auths (list) – (optional) required auths
- required_posting_auths (list) – (optional) posting auths
-
disallow
(foreign, permission='posting', account=None, threshold=None, **kwargs)¶ 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
active
) - 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
-
finalizeOp
(ops, account, permission, **kwargs)¶ 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)
- append_to (object) – This allows to provide an instance of
ProposalsBuilder (see
steem.new_proposal()
) or TransactionBuilder (seesteem.new_tx()
) to specify where to put a specific operation.
- … note::
append_to
is exposed to every method used in the - Steem class
… 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!
- … note:: This uses
beem.txbuffer
as instance of beem.transactionbuilder.TransactionBuilder
. You may want to use your own txbuffer
-
get_chain_properties
(use_stored_data=True)¶ Return witness elected chain properties
- ::
- {‘account_creation_fee’: ‘30.000 STEEM’,
- ‘maximum_block_size’: 65536, ‘sbd_interest_rate’: 250}
-
get_config
(use_stored_data=True)¶ Returns internal chain configuration.
-
get_current_median_history_price
(use_stored_data=True)¶ Returns the current median price
-
get_dynamic_global_properties
(use_stored_data=True)¶ This call returns the dynamic global properties
-
get_feed_history
(use_stored_data=True)¶ Returns the feed_history
-
get_hardfork_version
(use_stored_data=True)¶ Current Hardfork Version as String
-
get_median_price
()¶
-
get_network
(use_stored_data=True)¶ Identify the network
Returns: Network parameters Return type: dict
-
get_next_scheduled_hardfork
(use_stored_data=True)¶ Returns Hardfork and live_time of the hardfork
-
get_reward_fund
(fund_name='post', use_stored_data=True)¶ Get details for a reward fund.
-
get_state
(path='value')¶
-
get_steem_per_mvest
(time_stamp=None)¶
-
info
()¶ Returns the global properties
-
newWallet
(pwd)¶ Create a new wallet. This method is basically only calls
beem.wallet.create()
.Parameters: pwd (str) – Password to use for the new wallet Raises: beem.exceptions.WalletExists – if there is already a wallet created
-
new_tx
(*args, **kwargs)¶ Let’s obtain a new txbuffer
Returns int txid: id of the new txbuffer
-
prefix
¶
-
refresh_data
(force_refresh=False)¶
-
register_apis
(apis=['network_broadcast', 'account_by_key', 'follow', 'market_history'])¶
-
set_default_account
(account)¶ Set the default account to be used
-
sign
(tx=None, wifs=[])¶ 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.
Obtain the r-shares :param number sp: Steem Power :param int voting_power: voting power (100% = 10000) :param int vote_pct: voting participation (100% = 10000)
-
sp_to_sbd
(sp, voting_power=10000, vote_pct=10000)¶
-
sp_to_vests
(sp, timestamp=None)¶
-
tx
()¶ Returns the default transaction buffer
-
txbuffer
¶ Returns the currently active tx buffer
-
unlock
(*args, **kwargs)¶ Unlock the internal wallet
-
vests_to_sp
(vests, timestamp=None)¶