aergo.herapy package

Subpackages

Submodules

aergo.herapy.account module

class aergo.herapy.account.Account(private_key: Union[str, bytes, None] = None, empty: bool = False)[source]

Bases: object

Account can be a user account with private and public key, or a contract account.

address
balance
code_hash
static decrypt_account(encrypted_bytes: bytes, password: Union[str, bytes]) → aergo.herapy.account.Account[source]

https://cryptography.io/en/latest/hazmat/primitives/aead/ :param encrypted_bytes: encrypted data (bytes) of account :param password: to decrypt the exported bytes :return: account instance

static decrypt_from_keystore(keystore: Union[Dict[KT, VT], str], password: str) → aergo.herapy.account.Account[source]
static encrypt_account(account: aergo.herapy.account.Account, password: Union[str, bytes]) → bytes[source]

https://cryptography.io/en/latest/hazmat/primitives/aead/ :param account: account to export :return: encrypted account data (bytes)

static encrypt_to_keystore(account: aergo.herapy.account.Account, password: str, kdf_n: int = 262144) → Dict[KT, VT][source]
static from_json(data: Union[Dict[KT, VT], str], password: Union[bytes, str, None] = None) → aergo.herapy.account.Account[source]
json(password: Union[bytes, str, None] = None, with_private_key: bool = False) → Dict[KT, VT][source]
nonce
private_key
public_key
sign_msg_hash(msg_hash: bytes) → Optional[bytes][source]
sql_recovery_point
state
state_proof
storage_root
verify_proof(root: Union[str, bytes]) → bool[source]

verify that the given inclusion and exclusion proofs are correct

verify_sign(msg_hash: bytes, sign: bytes) → Optional[bool][source]

aergo.herapy.aergo module

Main module.

class aergo.herapy.aergo.Aergo[source]

Bases: object

Main class for herapy

account

Returns the account object. :return:

batch_call_sc(sc_txs: List[aergo.herapy.obj.transaction.Transaction]) → Tuple[List[aergo.herapy.obj.transaction.Transaction], List[aergo.herapy.obj.tx_result.TxResult]][source]
batch_tx(signed_txs: List[aergo.herapy.obj.transaction.Transaction]) → Tuple[List[aergo.herapy.obj.transaction.Transaction], List[aergo.herapy.obj.tx_result.TxResult]][source]

Send a set of signed transactions simultaneously. These transactions will push to the memory pool after verifying. :param signed_txs: :return:

call_sc(sc_address: Union[str, aergo.herapy.obj.address.GovernanceTxAddress, bytes], func_name: str, amount: int = 0, args: Optional[Any] = None, gas_limit: int = 0, gas_price: int = 0) → Tuple[aergo.herapy.obj.transaction.Transaction, aergo.herapy.obj.tx_result.TxResult][source]
connect(target: str, tls_ca_cert: Optional[str] = None, tls_cert: Optional[str] = None, tls_key: Optional[str] = None) → None[source]

Connect to the gRPC server running on port target e.g. target=”localhost:7845”. :param target: :param tls_ca_cert: :param tls_cert: :param tls_key: :return:

deploy_sc(payload: Union[str, bytes], amount: Union[bytes, str, int, float] = 0, args: Optional[Any] = None, retry_nonce: int = 0, redeploy: bool = False, gas_limit: int = 0, gas_price: int = 0)[source]
disconnect() → None[source]

Disconnect from the gRPC server.

export_account(password: Union[str, bytes], account: Optional[aergo.herapy.account.Account] = None) → str[source]
export_account_to_keystore(password: str, account: Optional[aergo.herapy.account.Account] = None, kdf_n: int = 262144) → Dict[KT, VT][source]
export_account_to_keystore_file(keystore_path: str, password: str, account: Optional[aergo.herapy.account.Account] = None, kdf_n: int = 262144) → None[source]
generate_tx(to_address: Union[bytes, str, None], nonce: int, amount: Union[bytes, str, int, float], gas_limit: int = 0, gas_price: int = 0, payload: Optional[bytes] = None, tx_type: aergo.herapy.obj.transaction.TxType = <TxType.NORMAL: 0>) → aergo.herapy.obj.transaction.Transaction[source]
get_abi(contract_addr: str = None, addr_bytes: bytes = None)[source]

Returns the abi of given contract address.

get_account(account: Optional[aergo.herapy.account.Account] = None, address: Union[str, bytes, aergo.herapy.obj.address.Address, None] = None, proof: bool = False, root: bytes = b'', compressed: bool = True) → aergo.herapy.account.Account[source]

Return account information :param address: :param proof: :param root: :param compressed: :return:

get_address(account: Optional[aergo.herapy.account.Account] = None) → Optional[aergo.herapy.obj.address.Address][source]
get_block(block_hash: Union[bytes, aergo.herapy.obj.block_hash.BlockHash, None] = None, block_height: int = -1) → aergo.herapy.obj.block.Block[source]

Returns block information for block_hash or block_height. :param block_hash: :param block_height: :return:

get_block_headers(block_hash: Optional[bytes] = None, block_height: int = -1, list_size: int = 20, offset: int = 0, is_asc_order: bool = False) → List[aergo.herapy.obj.block.Block][source]

Returns the list of blocks. :param block_hash: :param block_height: :param list_size: maximum number of results :param offset: the start point to search until the block_hash or block_height :param is_asc_order: :return:

get_block_meta(block_hash: Union[bytes, aergo.herapy.obj.block_hash.BlockHash, None] = None, block_height: int = -1) → aergo.herapy.obj.block.Block[source]

Returns block metadata for block_hash or block_height. :param block_hash: :param block_height: :return:

get_block_metas(block_hash: Optional[bytes] = None, block_height: int = -1, list_size: int = 20, offset: int = 0, is_asc_order: bool = False) → List[aergo.herapy.obj.block.Block][source]

Returns the list of metadata of queried blocks. :param block_hash: :param block_height: :param list_size: maximum number of results :param offset: the start point to search until the block_hash or block_height :param is_asc_order: :return:

get_blockchain_status() → Tuple[aergo.herapy.obj.block_hash.BlockHash, int][source]

Returns the highest block hash and block height so far. :return:

get_chain_info(with_consensus_info: bool = True) → aergo.herapy.obj.blockchain_info.BlockchainInfo[source]

Returns the blockchain info :return:

get_conf_change_progress(block_height: int) → aergo.herapy.obj.change_conf_info.ChangeConfInfo[source]

Returns the RAFT change config progress status after ‘changeCluster’ system contract :return:

get_consensus_info() → aergo.herapy.obj.consensus_info.ConsensusInfo[source]

Returns the consensus information :return:

get_enterprise_config(key: str) → aergo.herapy.obj.enterprise_config.EnterpriseConfig[source]
get_events(sc_address: Union[bytes, str, aergo.herapy.obj.tx_hash.TxHash], event_name: str, start_block_no: int = -1, end_block_no: int = -1, with_desc: bool = False, arg_filter: Union[str, Dict[KT, VT], List[T], Tuple, None] = None, recent_block_cnt: int = 0) → List[aergo.herapy.obj.event.Event][source]
get_name_info(name: str, block_height: int = -1)[source]

Returns information of name which is designated by the system contract :param name: :param block_height: :return:

get_node_accounts(skip_state: bool = False) → List[aergo.herapy.account.Account][source]

Returns a list of all node accounts. :return:

get_node_info(keys: Optional[str] = None) → aergo.herapy.obj.node_info.NodeInfo[source]

Returns the consensus information :return:

get_node_state(timeout: int = 1) → Dict[KT, VT][source]

Returns information about the node state. :return:

get_peers() → List[aergo.herapy.obj.peer.Peer][source]

Returns a list of peers. :return:

get_status() → aergo.herapy.obj.blockchain_status.BlockchainStatus[source]

Returns the blockchain status :return:

get_tx(tx_hash: Union[str, aergo.herapy.obj.tx_hash.TxHash, bytes], mempool_only: bool = False, skip_block: bool = False) → aergo.herapy.obj.transaction.Transaction[source]

Returns info on transaction with hash tx_hash. :param tx_hash: :return:

get_tx_result(tx_hash: Union[str, aergo.herapy.obj.tx_hash.TxHash, bytes]) → aergo.herapy.obj.tx_result.TxResult[source]
import_account(exported_data: Union[str, bytes], password: Union[str, bytes], skip_state: bool = False, skip_self: bool = False) → aergo.herapy.account.Account[source]
import_account_from_keystore(keystore: Union[Dict[KT, VT], str], password: str, skip_state: bool = False, skip_self: bool = False) → aergo.herapy.account.Account[source]
import_account_from_keystore_file(keystore_path: str, password: str, skip_state: bool = False, skip_self: bool = False) → aergo.herapy.account.Account[source]
lock_account(address: bytes, passphrase: str)[source]

Locks the account with address address with the passphrase passphrase. :param address: :param passphrase: :return:

new_account(private_key: Union[str, bytes, None] = None, skip_state: bool = False) → aergo.herapy.account.Account[source]
new_call_sc_tx(sc_address: Union[str, aergo.herapy.obj.address.GovernanceTxAddress, bytes], func_name: str, amount: int = 0, args: Optional[Any] = None, nonce: Optional[int] = None, gas_limit: int = 0, gas_price: int = 0) → aergo.herapy.obj.transaction.Transaction[source]
query_sc(sc_address: Union[bytes, str], func_name: str, args: Optional[Any] = None)[source]
query_sc_state(sc_address: Union[bytes, str], storage_keys: List[Union[bytes, str, aergo.herapy.obj.sc_state.SCStateVar]], root: bytes = b'', compressed: bool = True) → aergo.herapy.obj.sc_state.SCState[source]

query_sc_state returns a SCState object containing the contract state and variable state with their respective merkle proofs.

receive_block_meta_stream() → aergo.herapy.obj.block_stream.BlockStream[source]

Returns the iterable block stream :return:

receive_block_stream() → aergo.herapy.obj.block_stream.BlockStream[source]

Returns the iterable block stream :return:

receive_event_stream(sc_address: Union[str, bytes, aergo.herapy.obj.tx_hash.TxHash], event_name: str, start_block_no: int = 0, end_block_no: int = 0, with_desc: bool = False, arg_filter: Union[str, Dict[KT, VT], List[T], Tuple, None] = None, recent_block_cnt: int = 0) → aergo.herapy.obj.event_stream.EventStream[source]
send_payload(amount: Union[bytes, str, int, float], payload: Optional[bytes] = None, to_address: Union[str, bytes, aergo.herapy.obj.address.Address, aergo.herapy.obj.address.GovernanceTxAddress, None] = None, retry_nonce: int = 0, tx_type: aergo.herapy.obj.transaction.TxType = <TxType.TRANSFER: 4>, gas_limit: int = 0, gas_price: int = 0) → Tuple[aergo.herapy.obj.transaction.Transaction, aergo.herapy.obj.tx_result.TxResult][source]
send_tx(signed_tx: aergo.herapy.obj.transaction.Transaction) → Tuple[aergo.herapy.obj.transaction.Transaction, aergo.herapy.obj.tx_result.TxResult][source]

Send a signed transaction. This transaction will push to the memory pool after verifying. :param signed_tx: :return:

send_unsigned_tx(unsigned_tx: aergo.herapy.obj.transaction.Transaction)[source]

Sends the unsigned transaction. The unsigned transaction will be signed by the account which is stored in the connected node. :param unsigned_tx: :return:

transfer(to_address: Union[str, bytes, aergo.herapy.obj.address.Address, aergo.herapy.obj.address.GovernanceTxAddress], amount: Union[bytes, str, int, float], retry_nonce: int = 3) → Tuple[aergo.herapy.obj.transaction.Transaction, aergo.herapy.obj.tx_result.TxResult][source]
unlock_account(address: bytes, passphrase: str)[source]

Unlocks the account with address address with the passphrase passphrase. :param address: :param passphrase: :return:

wait_tx_result(tx_hash: Union[str, aergo.herapy.obj.tx_hash.TxHash, bytes], timeout: int = 30, tempo: float = 0.2) → aergo.herapy.obj.tx_result.TxResult[source]

aergo.herapy.comm module

Communication(grpc) module.

class aergo.herapy.comm.Comm(target: Optional[str] = None, tls_ca_cert: Optional[bytes] = None, tls_cert: Optional[bytes] = None, tls_key: Optional[bytes] = None)[source]

Bases: object

add_raft_member(request_id: int, member_id: int, member_name: str, member_address: str, member_peer_id: bytes)[source]
commit_txs(signed_txs: List[aergo.herapy.obj.transaction.Transaction])[source]
connect()[source]
create_account(address: bytes, passphrase: str)[source]
del_raft_member(request_id: int, member_id: int, member_name: str, member_address: str, member_peer_id: bytes)[source]
disconnect()[source]
get_abi(addr_bytes: bytes)[source]
get_account_state(address: bytes)[source]
get_account_state_proof(address: bytes, root: bytes, compressed: bool)[source]
get_accounts()[source]
get_block(query: bytes)[source]
get_block_headers(block_hash: Optional[bytes], block_height: int, list_size: int, offset: int, is_asc_order: bool)[source]
get_block_meta(query: bytes)[source]
get_block_metas(block_hash: Optional[bytes], block_height: int, list_size: int, offset: int, is_asc_order: bool)[source]
get_block_tx(tx_hash: bytes)[source]
get_blockchain_status()[source]
get_chain_info()[source]
get_conf_change_progress(block_height: int)[source]
get_consensus_info()[source]
get_enterprise_config(key: str)[source]
get_events(sc_address: bytes, event_name: str, start_block_no: int, end_block_no: int, with_desc: bool, arg_filter: Optional[bytes], recent_block_cnt: int)[source]
get_name_info(name: str, block_height: int)[source]
get_node_info(keys: Optional[str])[source]
get_node_state(timeout: int)[source]
get_peers()[source]
get_receipt(tx_hash: bytes)[source]
get_tx(tx_hash: bytes)[source]
lock_account(address: bytes, passphrase: str)[source]
query_contract(sc_address: bytes, query_info: bytes)[source]
query_contract_state(sc_address: bytes, storage_keys: List[bytes], root: bytes, compressed: bool)[source]
receive_block_meta_stream()[source]
receive_block_stream()[source]
receive_event_stream(sc_address: bytes, event_name: str, start_block_no: int, end_block_no: int, with_desc: bool, arg_filter: Optional[bytes], recent_block_cnt: int)[source]
send_tx(unsigned_tx: aergo.herapy.obj.transaction.Transaction)[source]
unlock_account(address: bytes, passphrase: str)[source]

aergo.herapy.constants module

Module contents

Top-level package for herapy.