accounts Module¶
The accounts module of Solidbyte.
Objects and utility functions for account operations
-
class
solidbyte.accounts.Accounts(network_name: str = None, keystore_dir: str = None, web3: web3.main.Web3 = None)[source]¶ Deal with local Ethereum secret store account operations
-
__init__(network_name: str = None, keystore_dir: str = None, web3: web3.main.Web3 = None) → None[source]¶ Init Accounts
Parameters: - network_name – (
str) - The name of the network as defined in networks.yml. - keystore_dir – (
pathlib.Path) - Path to the keystore. (default:~/.ethereum/keystore) - web3 – (
web3.Web3) - The Web3 instance to use
- network_name – (
-
account_known(address: str) → bool[source]¶ Check if an account is known
Parameters: address – ( str) Address of an account to check for
-
accounts¶ Return all the known account addresses
Returns: ( list) of account addresses
-
create_account(password: str) → str[source]¶ Create a new account and encrypt it with password
Parameters: password – ( str) Password to use to encrypt the new accountReturns: ( str) address of the new account
-
get_account(address: str) → attrdict.dictionary.AttrDict[source]¶ Return all the known account addresses
Parameters: address – ( str) Address of account to getReturns: ( attrdict.AttrDict) of the account
-
get_accounts() → List[attrdict.dictionary.AttrDict][source]¶ Return all the known account addresses
Returns: ( list) of account addresses
-
set_account_attribute(address: str, key: str, val: T) → None[source]¶ Set an attribute of an account
Parameters: - address – (
str) address of account - key – (
str) name of the attribute to set - val – (
T) new value of the attribute
- address – (
-
sign_tx(account_address: str, tx: dict, password: str = None) → str[source]¶ Sign a transaction using the provided account
Parameters: - account_address – (
str) address of the account to unlock - tx – (
dict) transaction object to sign - password – (
str) password to use to decrypt the account
Returns: (
str) transaction hash if successful- account_address – (
-
unlock(account_address: str, password: str = None) → bytes[source]¶ Unlock an account keystore file and return the private key
Parameters: - account_address – (
str) address of the account to unlock - password – (
str) password to use to decrypt the account
Returns: (
bytes) The account’s private key if decryption is successful- account_address – (
-