shell.account

class eosfactory.shell.account.Account[source]

Bases: object

Methods to be ascribed to account objects, produced with create_master_account() factories and create_account().

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.

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, authority, parent_permission_name, 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 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.
  • 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.

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='', 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.

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, key='', lower='', upper='')[source]

Retrieve the contents of a database table

Parameters:
  • scope (str or interface.Account) – The scope within the account in which the table is found.
  • table (str) – The name of the table as specified by the contract abi.
  • 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.
Returns:

cleos_set.SetTable object

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 master 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.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.