core.cleos

class eosfactory.core.cleos.Cleos(args, command_group, command, is_verbose=True)[source]

Bases: object

A prototype for EOSIO cleos commands. Calls EOSIO cleos, and processes the responce.

Parameters:
  • args (list) – List of EOSIO cleos positionals and options.
  • command_group (str) – Command group name.
  • command (str) – Command name.
Variables:
  • out_msg (str) – Responce received via the stdout stream.
  • out_msg_details (str) – Responce received via the stderr stream.
  • err_msg (str) – Error message received via the stderr stream.
  • json (json) – Responce received as JSON, if any.
  • is_verbose (bool) – If set, a message is printed.
  • args (list) – Value of the args argument.
Raises:

core.errors.Error – If err_msg.

printself(is_verbose=False)[source]

Print a message.

Parameters:is_verbose (bool) – If set, a message is printed.
class eosfactory.core.cleos.CreateAccount(creator, name, owner_key, active_key=None, permission=None, expiration_sec=None, skip_sign=0, dont_broadcast=0, force_unique=0, max_cpu_usage=0, max_net_usage=0, ref_block=None, delay_sec=0, is_verbose=True)[source]

Bases: eosfactory.core.interface.Account, eosfactory.core.cleos.Cleos

Create an account, buy ram, stake for bandwidth for the account.

Parameters:
  • creator (str or interface.Account) – The account creating the new account.
  • name – (str) The name of the new account.
  • owner_key (str) – If set, the owner public key for the new account, otherwise random.
  • active_key (str) – If set, the active public key for the new account, otherwise random.

See definitions of the remaining parameters: cleos.common_parameters().

class eosfactory.core.cleos.CreateKey(key_public=None, key_private=None, r1=False, is_verbose=True)[source]

Bases: eosfactory.core.interface.Key, eosfactory.core.cleos.Cleos

Create a new keypair and print the public and private keys.

Parameters:
  • key_private (str) – If set, a private key to set, otherwise random.
  • key_public (str) – If set, a public key to set, otherwise random.
  • r1 – Generate a key using the R1 curve (iPhone), instead of the K1 curve (Bitcoin)
  • is_verbose (bool) – If False do not print. Default is True.
Variables:
  • key_private (str) – The private key set.
  • key_public (str) – The public key set.
class eosfactory.core.cleos.GetAccount(account, is_info=True, is_verbose=True)[source]

Bases: eosfactory.core.interface.Account, eosfactory.core.cleos.Cleos

Retrieve an account from the blockchain.

Parameters:
  • account (str or interface.Account) – The account to retrieve.
  • is_verbose (bool) – If False do not print. Default is True.
Variables:
  • name (str) – The EOSIO name of the account.
  • owner_key (str) –
  • active_key (str) –
class eosfactory.core.cleos.GetTransaction(transaction_id, block_hint=None, is_verbose=True)[source]

Bases: eosfactory.core.cleos.Cleos

Retrieve a transaction from the blockchain.

Parameters:
  • transaction_id (str) – ID of the transaction to retrieve.
  • block_hint (int) – If set, the block number this transaction may be in.
  • is_verbose (bool) – If False do not print. Default is True.
Variables:
  • transaction_id – The ID of the transaction retrieved.
  • json – The transaction retrieved.
class eosfactory.core.cleos.PushAction(account, action, data, permission=None, expiration_sec=None, skip_sign=0, dont_broadcast=0, force_unique=0, max_cpu_usage=0, max_net_usage=0, ref_block=None, delay_sec=0, is_verbose=True, json=False)[source]

Bases: eosfactory.core.cleos.Cleos

Push a transaction with a single action.

Parameters:
  • account (str or interface.Account) – The account to publish a contract for.
  • action (str or json or filename) – Definition of the action to execute on the contract.
  • data (str) – The arguments to the contract.

See definitions of the remaining parameters: cleos.common_parameters().

Variables:
  • account_name (str) – The EOSIO name of the contract’s account.
  • console (str) – Sum of all [“processed”][“action_traces”][][“console”] components of EOSIO cleos responce.
  • act (str) – Summary of all actions, like eosio.null::nonce <= 5d0a572c49880500.
class eosfactory.core.cleos.RestoreAccount(account, is_verbose=True)[source]

Bases: eosfactory.core.cleos.GetAccount

class eosfactory.core.cleos.WalletCreate(name='default', password='', is_verbose=True)[source]

Bases: eosfactory.core.interface.Wallet, eosfactory.core.cleos.Cleos

Create a new wallet locally.

If the password argument is set, try to open a wallet. Otherwise, create a new wallet.

Parameters:
  • name (str) – The name of the wallet, defaults to default.
  • password (str) – The password to the wallet, if the wallet exists.
  • is_verbose (bool) – If False do not print. Default is True.
Variables:
  • name (str) – The name of the wallet.
  • password (str) – The password returned by the wallet create EOSIO cleos command.
  • is_created (bool) – True, if the wallet created.
class eosfactory.core.cleos.WalletImport(key, wallet='default', is_verbose=True)[source]

Bases: eosfactory.core.cleos.Cleos

Import a private key into wallet.

Parameters:
  • wallet (str or interface.Wallet) – A wallet to import key into.
  • key (str or interface.Key) – A key to import.
  • is_verbose (bool) – If False do not print. Default is True.
Variables:

key_private (str) –

class eosfactory.core.cleos.WalletKeys(is_verbose=True)[source]

Bases: eosfactory.core.cleos.Cleos

List of public keys from all unlocked wallets.

Parameters:is_verbose (bool) – If False do not print. Default is True.
class eosfactory.core.cleos.WalletList(is_verbose=True)[source]

Bases: eosfactory.core.cleos.Cleos

List opened wallets, * marks unlocked.

Parameters:is_verbose (bool) – If False do not print. Default is True.
Variables:json – The list of the open wallets.
class eosfactory.core.cleos.WalletLock(wallet='default', is_verbose=True)[source]

Bases: eosfactory.core.cleos.Cleos

Lock wallet.

Parameters:
  • wallet (str or interface.Wallet) – The wallet to open.
  • is_verbose (bool) – If False do not print. Default is True.
class eosfactory.core.cleos.WalletLockAll(is_verbose=True)[source]

Bases: eosfactory.core.cleos.Cleos

Lock all unlocked wallets.

Parameters:is_verbose (bool) – If False do not print. Default is True.
class eosfactory.core.cleos.WalletOpen(wallet='default', is_verbose=True)[source]

Bases: eosfactory.core.cleos.Cleos

Open an existing wallet.

Parameters:
  • wallet (str or interface.Wallet) – The wallet to open.
  • is_verbose (bool) – If False do not print. Default is True.
class eosfactory.core.cleos.WalletRemove_key(key, wallet, password, is_verbose=True)[source]

Bases: eosfactory.core.cleos.Cleos

Remove key from wallet

Parameters:
  • wallet (str or interface.Wallet) – The wallet to remove key from.
  • password (str) – The password returned by wallet create.
  • key (str or interface.Key) – A public key to remove.
  • is_verbose (bool) – If False do not print. Default is True.
Variables:

key_public (str) – The public key removed.

class eosfactory.core.cleos.WalletStop(is_verbose=True)[source]

Bases: eosfactory.core.cleos.Cleos

Stop keosd, the EOSIO wallet manager.

Parameters:is_verbose (bool) – If False do not print. Default is True.
class eosfactory.core.cleos.WalletUnlock(wallet='default', password='', timeout=0, is_verbose=True)[source]

Bases: eosfactory.core.cleos.Cleos

Unlock wallet.

Parameters:
  • wallet (str or interface.Wallet) – The wallet to remove key from.
  • password (str) – The password returned by wallet create.
  • is_verbose (bool) – If False do not print. Default is True.
eosfactory.core.cleos.account_name()[source]

Get a random EOSIO account name.

eosfactory.core.cleos.common_parameters(permission=None, expiration_sec=None, skip_sign=False, dont_broadcast=False, force_unique=False, max_cpu_usage=0, max_net_usage=0, ref_block=None, delay_sec=0)[source]

Common parameters.

Parameters:permission (interface.Account or str or (str, str) or (interface.Account, str) or any list of the previous items.) – An account and permission level to authorize.

Exemplary values of the argument permission:

eosio # eosio is interface.Account object

"eosio@owner"

("eosio", "owner")

(eosio, interface.Permission.ACTIVE)

["eosio@owner", (eosio, .Permission.ACTIVE)]
Parameters:
  • expiration (int) – The time in seconds before a transaction expires, defaults to 30s
  • skip_sign (bool) – Specify if unlocked wallet keys should be used to sign transaction.
  • dont_broadcast (bool) – Don’t broadcast transaction to the network (just print).
  • force_unique (bool) – Force the transaction to be unique. This will consume extra bandwidth and remove any protections against accidentally issuing the same transaction multiple times.
  • max_cpu_usage (int) – Upper limit on the milliseconds of cpu usage budget, for the execution of the transaction (defaults to 0 which means no limit).
  • max_net_usage (int) – Upper limit on the net usage budget, in bytes, for the transaction (defaults to 0 which means no limit).
  • ref_block (int) – The reference block num or block id used for TAPOS (Transaction as Proof-of-Stake).
  • delay_sec – The delay in seconds, defaults to 0s.
eosfactory.core.cleos.contract_is_built(contract_dir, wasm_file=None, abi_file=None)[source]

Check whether the given contract project has its ABI and WASM files.

Parameters:
  • contract_dir (str) – A hint to the project root directory.
  • wasm_file (str) – If set, the WASM file.
  • abi_file (str) – If set, the ABI file.
Returns:

[<absolute contract dir>, <wasm file>, <abi file>]