shell.account

class eosfactory.shell.account.Account[source]

Bases: object

Methods to be ascribed to account objects.

actions(pos=-1, offset=1, json=True, full=False, pretty=False, console=False)[source]

Retrieve all actions with specific account name referenced in authorization or receiver.

Note that available actions are filtered. By default, all actions are filered off. To see the actions, the node has to be restarted with the –filter-on option.

Parameters:
  • account (str) – Name of account to query on.
  • pos (int) – Sequence number of action for this account, -1 for last. Default is -1.
  • offset (int) – Get actions [pos,pos+offset] for positive offset or [pos-offset,pos) for negative offset. Default is 1.
  • json (bool) – Responce received as JSON, if any. Default is True.
  • full (bool) – Don’t truncate action json. Default is False.
  • pretty (bool) – Pretty print full action json. Default is False.
  • console (bool) – print console output generated by action. Default is False.
classmethod add_methods_and_finalize(account_object_name, account)[source]

Ascribes methodes to the given account, and finalizes the creation of this account.

code(code=None, abi=None, wasm=False)[source]

Retrieve the code and ABI

Parameters:
  • code (str) – If set, the name of the file to save the contract WAST/WASM to.
  • abi (str) – If set, the name of the file to save the contract ABI to.
  • wasm (bool) – Save contract as wasm.
is_code()[source]

Determine whether any contract is set to the account.

Returns:True if the retrieved hash code of the contract code is not null.
push_action(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)[source]

Push a transaction with a single action.

Call EOSIO cleos with the push action command. Store the result, which is an object of the class cleos.PushAction, as the value of the action attribute.

Parameters:
  • action (str or json or filename) – Definition of the action to execute on the contract.
  • data (str) – The arguments to the contract, defaults to empty json.
  • permission – defaults to self.

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

Variables:
  • account_name (str) – The EOSIO name of the contract’s account.
  • console (str) – [“processed”][“action_traces”][0][“console”] component of EOSIO cleos responce.
  • data (str) – [“processed”][“action_traces”][0][“act”][“data”] component of EOSIO cleos responce.
set_account_permission(permission_name=None, authority=None, parent_permission_name=None, permission=None, add_code=False, remove_code=False, expiration_sec=None, skip_sign=0, dont_broadcast=0, return_packed=0, force_unique=0, max_cpu_usage=0, max_net_usage=0, ref_block=None, delay_sec=0)[source]

Set parameters dealing with account permissions.

Call EOSIO cleos with the set account permission command. Store the result, which is an object of the class cleos_set.SetAccountPermission, as the value of the account_permission attribute.

Parameters:
  • permission_name (str or Permission) – The permission to set/delete an authority for (defaults to: “active”).
  • parent_permission_name (str or Permission) – The permission name of this parents permission (defaults to: “active”).
  • authority (str or dict or filename) – None to delete.
  • add_code (bool) – If set, add ‘eosio.code’ permission to specified permission authority. Default is false.
  • remove_code (bool) – If set, remove ‘eosio.code’ permission from specified permission authority. Default is false.

Exemplary values of the argument authority:

# bob, carol are account objects created with
# shell.account.create_account factory function

str_value = "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"

permission_value = bob.active()

dict_value = {
    "threshold" : 100,
    "keys" : [],
    "accounts" :
        [
            {
                "permission":
                    {
                        "actor": bob.active(),
                        "permission":"active"
                    },
                "weight":100
            }
        ]
}

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

set_action_permission(code, type, requirement, permission=None, expiration_sec=None, skip_sign=0, dont_broadcast=0, return_packed=0, force_unique=0, max_cpu_usage=0, max_net_usage=0, ref_block=None, delay_sec=0)[source]

Set parameters dealing with account permissions.

Call EOSIO cleos with the set action permission command. Store the result, which is an object of the class cleos_set.SetActionPermission, as the value of the action_permission attribute.

Parameters:
  • code (str or interface.Account) – The account that owns the code for the action.
  • type (str) – The type of the action.
  • requirement (str) – The permission name require for executing the given action.

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

set_contract(contract_dir, wasm_file='', abi_file='', clear=False, 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)[source]

Create or update the contract.

Call EOSIO cleos with the set contract command. Store the result, which is an object of the class cleos_set.SetContract, as the value of the set_contract attribute.

Parameters:
  • contract_dir (str) – A path to a directory.
  • wasm_file (str) – The WASM file relative to the contract_dir.
  • abi_file (str) – The ABI file for the contract, relative to the contract-dir.
  • clear (bool) – Remove contract on an account. Default is False.

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

show_action(action, data, permission=None, expiration_sec=None, skip_sign=0, force_unique=0, max_cpu_usage=0, max_net_usage=0, ref_block=None, delay_sec=0)[source]

Implement the push action command without broadcasting.

table(table_name, scope='', binary=False, limit=10, lower='', upper='', index='', key_type='', encode_type='', reverse=False, show_payer=False)[source]

Retrieve the contents of a database table

Parameters:
  • table (str) – The name of the table as specified by the contract abi.
  • scope (str or interface.Account) – The scope within the account in which the table is found.
  • binary (bool) – Return the value as BINARY rather than using abi to interpret as JSON. Default is False.
  • limit (int) – The maximum number of rows to return. Default is 10.
  • lower (str) – JSON representation of lower bound value of key, defaults to first.
  • upper (str) – JSON representation of upper bound value value of key, defaults to last.
  • index (int or str) – Index number, 1 - primary (first), 2 - secondary index (in order defined by multi_index), 3 - third index, etc. Number or name of index can be specified, e.g. ‘secondary’ or ‘2’.
  • key_type (str) – The key type of –index, primary only supports (i64), all others support (i64, i128, i256, float64, float128, ripemd160, sha256). Special type ‘name’ indicates an account name.
  • encode_type (str) – The encoding type of key_type (i64 , i128 , float64, float128) only support decimal encoding e.g. ‘dec’i256 - supports both ‘dec’ and ‘hex’, ripemd160 and sha256 is ‘hex’ only.
  • reverse (bool) – Iterate in reverse order.
  • show_payer (bool) – Show RAM payer.
Returns:

cleos_set.SetTable object

class eosfactory.shell.account.MasterAccount(account_object_name=None)[source]

Bases: eosfactory.core.account.Eosio

Dummy class for declaring master account objects.

eosfactory.shell.account.create_account(account_object_name, creator, account_name='', owner_key='', active_key='', stake_net=3, stake_cpu=3, 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, buy_ram_kbytes=8, buy_ram='', transfer=False, restore=False)[source]

Create account object in caller’s global namespace.

Parameters:
  • account_object_name (str) – The name of the account object returned.
  • creator (str or core.interface.Account) – The account creating the new account
  • account_name (str) – The name of an valid EOSIO account. If not set, it is random.
  • owner_key (core.interface.Key) – The owner key pair. If not set, it is random.
  • active_key (core.interface.Key) – The active key pair. If not set, and the owner_key is set, it is substituted with the owner_key. Otherwise, it is random.
  • stake_net (int) – The amount of EOS delegated for net bandwidth.
  • stake_cpu (int) – The amount of EOS delegated for CPU bandwidth.
  • buy_ram_kbytes (int) – The amount of RAM bytes to purchase.
  • transfer (bool) – Transfer voting power and right to unstake EOS to receiver.

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

eosfactory.shell.account.create_master_account(account_object_name, account_name=None, owner_key=None, active_key=None)[source]

Create master account object in caller’s global namespace.

Start a singleton shell.wallet.Wallet object if there is no one in the global namespace already.

If a local testnet is running, create an account object representing the eosio account. Put the account into the wallet. Put the account object into the global namespace of the caller, and return.

Otherwise, an outer testnet has to be defined with the function core.setup.set_nodeos_address().

If the account_name argument is set, check the testnet for presence of the account. If present, create a corresponding object and put the account into the wallet, and put the account object into the global namespace of the caller, and return.

Otherwise start a registration procedure:

  • if the argument account_name is not set, make it random
  • print registration data, namely:
    • account name
    • owner public key
    • active public key
    • owner private key
    • active private key
  • wait for the user to register the master account
  • … .
  • detect the named account on the remote testnet
  • put the account into the wallet
  • put the account object into the global namespace of the caller and return
Note: Name conflict:
If a new account object, named as an existing one, is going to be added to the wallet, an error is reported. Then an offer is given to edith the mapping file in order to resolve the conflict. When the conflict is resolved, the procedure finishes successfully.
Parameters:
  • account_object_name (str) – The name of the account object returned.
  • account_name (str or core.testnet.Testnet) – The name of an valid EOSIO account. Must be set if the testnode is not local.
  • owner_key (str or core.interface.Key) – The owner public key. Must be set if the testnode is not local.
  • active_key (str or core.interface.Key) – The active public key. Must be set if the testnode is not local.
eosfactory.shell.account.new_account(creator, account_name='', owner_key='', active_key='', stake_net=3, stake_cpu=3, 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, buy_ram_kbytes=8, buy_ram='', transfer=False, restore=False)[source]

Create account object in caller’s global namespace.

Wraps the account factory function create_account() so that the following statements are equivalent:

foo = create_account("foo", MASTER)
foo = new_account(MASTER)

NOTE:

With the `create_` syntax it is enough to state
`create_account("foo", MASTER)` in order to create the account object `foo`.
Parameters:
  • creator (str or core.interface.Account) – The account creating the new account
  • account_name (str) – The name of an valid EOSIO account. If not set, it is random.
  • owner_key (core.interface.Key) – The owner key pair. If not set, it is random.
  • active_key (core.interface.Key) – The active key pair. If not set, and the owner_key is set, it is substituted with the owner_key. Otherwise, it is random.
  • stake_net (int) – The amount of EOS delegated for net bandwidth.
  • stake_cpu (int) – The amount of EOS delegated for CPU bandwidth.
  • buy_ram_kbytes (int) – The amount of RAM bytes to purchase.
  • transfer (bool) – Transfer voting power and right to unstake EOS to receiver.

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

eosfactory.shell.account.new_master_account(account_name=None, owner_key=None, active_key=None)[source]

Create master account object in caller’s global namespace.

Wraps the account factory function create_master_account() so that the following statements are equivalent:

MASTER = create_master_account("MASTER")
MASTER = new_master_account()

NOTE:

With the `create_` syntax it is enough to state
`create_master_account("MASTER")` in order to create the account object
`MASTER`.
Parameters:
  • account_name (str or core.testnet.Testnet) – The name of an valid EOSIO account. Must be set if the testnode is not local.
  • owner_key (str or core.interface.Key) – The owner public key. Must be set if the testnode is not local.
  • active_key (str or core.interface.Key) – The active public key. Must be set if the testnode is not local.
eosfactory.shell.account.reboot()[source]

Reset the shell.account module.

eosfactory.shell.account.restore_account(account_object_name, testnet_account)[source]

Create a restored account object in caller’s global namespace.

Start a singleton shell.wallet.Wallet object if there is no one in the global namespace already.

If a local testnet is running, create an account object representing the eosio account. Put the account into the wallet. Put the account object into the global namespace of the caller, and return.

Otherwise, an outer testnet has to be defined with the function core.setup.set_nodeos_address().

Parameters:
  • account_object_name (str) – The name of the account object returned.
  • testnet_account (core.testnet.Testnet) – A testnet object defining the account to restore.