Welcome to Aergo HeraPy’s documentation!¶
Aergo HeraPy is the Python SDK for communicating and interacting with the Aergo blockchain.
What is Herapy?¶
HeraPy is Aergo’s Python3 SDK for connecting to Aergo networks.
It contains the following features:
- connect to an Aergo blockchain node
- create a new account
- manage an account
- create a transaction
- sign a transaction
- send a transaction
- deploy a smart contract
- call a smart contract
- query a smart contract
- request and verify state Merkle proofs
- and so on.
Getting Started¶
Let’s find out how to use HeraPy quickly with a few examples.
Installation¶
- Python3 (>= 3.7)
Setup your environment and install aergo-herapy
$ cd my_new_project
$ virtualenv -p python3 venv
$ source venv/bin/activate
$ pip install aergo-herapy
Connecting to Aergo¶
Connecting to Aergo can be done with a public api like ‘testnet-api.aergo.io:7845’ or by running your own Aergo node.
1 2 3 4 5 6 7 8 | import aergo.herapy as herapy
aergo = herapy.Aergo()
aergo.connect('testnet-api.aergo.io:7845')
print(aergo.get_chain_info())
aergo.disconnect()
|
Creating a new Account¶
Connecting to Aergo is optional when creating new accounts with the parameter skip_state=True.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import aergo.herapy as herapy
aergo = herapy.Aergo()
# connect to a node to retrieve the account state (nonce, balance...)
# aergo.connect('testnet-api.aergo.io:7845')
# aergo.new_account()
# create a new account offline
aergo.new_account(skip_state=True)
# print the address
print(aergo.get_address())
# print the address as bytes
print(bytes(aergo.get_address()))
|
Exporting/Importing an Account¶
For using an account created in various other SDKs and Aergocli, the prefered method is to import an Aergo encrypted keystore file.
Connecting to a node is optional.
1 2 3 4 5 6 7 8 | import aergo.herapy as herapy
aergo = herapy.Aergo()
aergo.new_account(skip_state=True)
exp_account = aergo.export_account_to_keystore("keep-safe")
aergo2 = herapy.Aergo()
aergo2.import_account_from_keystore(exp_account, "keep-safe", skip_state=True)
|
Creating a Transaction¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import aergo.herapy as herapy
# connect to a node
aergo = herapy.Aergo()
aergo.connect('testnet-api.aergo.io:7845')
keystore_file_path = "./my/keystore.json"
# import account from keystore file and get current nonce
aergo.import_account_from_keystore_file(keystore_file_path, "keep-safe")
# transfer 1 aergo
tx, status = aergo.transfer(to_address, 1 * 10**18)
assert result.status == herapy.CommitStatus.TX_OK
receipt = aergo.wait_tx_result(tx.tx_hash)
assert receipt.status == herapy.TxResultStatus.SUCCESS:
|
Deploying and calling smart contracts¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | import aergo.herapy as herapy
# connect to a node
aergo = herapy.Aergo()
aergo.connect('testnet-api.aergo.io:7845')
keystore_file_path = "./my/keystore.json"
# import account from keystore file and get current nonce
aergo.import_account_from_keystore_file(keystore_file_path, "keep-safe")
# deploy a new contract
payload = "Compiled contract string"
tx, result = aergo.deploy_sc(amount=0, payload=payload, args=1234)
assert result.status == herapy.CommitStatus.TX_OK
receipt = aergo.wait_tx_result(tx.tx_hash)
assert receipt.status == herapy.TxResultStatus.CREATED:
# get address of newly deployed contract
sc_address = receipt.contract_address
# send a transaction to a contract (write)
tx, result = aergo.call_sc(sc_address, "lua function name")
assert result.status == herapy.CommitStatus.TX_OK
assert receipt.status == herapy.TxResultStatus.SUCCESS:
receipt = aergo.wait_tx_result(tx.tx_hash)
# query a contract function (read-only)
return_value = aergo.query_sc(sc_address, "lua function name")
|
Modules¶
The documentation is being written so for other tools and advanced features, please refer to the herapy.aergo and herapy.account modules description below.
aergo.herapy package¶
Subpackages¶
aergo.herapy.errors package¶
Submodules¶
aergo.herapy.errors.InsufficientBalanceError module¶
aergo.herapy.errors.conversion_exception module¶
aergo.herapy.errors.exception module¶
-
exception
aergo.herapy.errors.exception.
AergoException
(error, exception_type)[source]¶ Bases:
Exception
-
Comm
= 'Communication Exception'¶
-
Conv
= 'Conversion Exception'¶
-
General
= 'General Exception'¶
-
aergo.herapy.errors.general_exception module¶
Module contents¶
aergo.herapy.grpc package¶
Submodules¶
aergo.herapy.grpc.account_pb2 module¶
aergo.herapy.grpc.account_pb2_grpc module¶
aergo.herapy.grpc.blockchain_pb2 module¶
aergo.herapy.grpc.blockchain_pb2_grpc module¶
aergo.herapy.grpc.metric_pb2 module¶
aergo.herapy.grpc.metric_pb2_grpc module¶
aergo.herapy.grpc.node_pb2 module¶
aergo.herapy.grpc.node_pb2_grpc module¶
aergo.herapy.grpc.p2p_pb2 module¶
aergo.herapy.grpc.p2p_pb2_grpc module¶
aergo.herapy.grpc.pmap_pb2 module¶
aergo.herapy.grpc.pmap_pb2_grpc module¶
aergo.herapy.grpc.polarrpc_pb2 module¶
aergo.herapy.grpc.polarrpc_pb2_grpc module¶
aergo.herapy.grpc.raft_pb2 module¶
aergo.herapy.grpc.raft_pb2_grpc module¶
aergo.herapy.grpc.rpc_pb2 module¶
aergo.herapy.grpc.rpc_pb2_grpc module¶
-
class
aergo.herapy.grpc.rpc_pb2_grpc.
AergoRPCServiceServicer
[source]¶ Bases:
object
AergoRPCService is the main RPC service providing endpoints to interact with the node and blockchain. If not otherwise noted, methods are unary requests.
-
Blockchain
(request, context)[source]¶ Returns current blockchain status (best block’s height and hash)
-
GetBlock
(request, context)[source]¶ Return a single block incl. header and body, queried by hash or number
-
GetBlockBody
(request, context)[source]¶ Return a single block’s body, queried by hash or number and list parameters
-
GetBlockMetadata
(request, context)[source]¶ Return a single block’s metdata (hash, header, and number of transactions), queried by hash or number
-
GetBlockTX
(request, context)[source]¶ Return information about transaction in block, queried by transaction hash
-
GetConfChangeProgress
(request, context)[source]¶ Return a status of changeCluster enterprise tx, queried by requestID
-
ListBlockHeaders
(request, context)[source]¶ Returns list of Blocks without body according to request
-
ListBlockMetadata
(request, context)[source]¶ Returns list of block metadata (hash, header, and number of transactions) according to request
-
ListBlockMetadataStream
(request, context)[source]¶ Returns a stream of new block’s metadata as they get added to the blockchain
-
ListBlockStream
(request, context)[source]¶ Returns a stream of new blocks as they get added to the blockchain
-
Module contents¶
grpc package for herapy.
aergo.herapy.obj package¶
Submodules¶
aergo.herapy.obj.abi module¶
aergo.herapy.obj.address module¶
-
class
aergo.herapy.obj.address.
Address
(pubkey: Union[str, bytes, ecdsa.ecdsa.Public_key], empty: bool = False, curve: ecdsa.curves.Curve = SECP256k1)[source]¶ Bases:
object
-
curve
¶
-
public_key
¶
-
value
¶
-
aergo.herapy.obj.aer module¶
aergo.herapy.obj.aergo_conf module¶
-
class
aergo.herapy.obj.aergo_conf.
AergoConfig
[source]¶ Bases:
object
-
account
¶
-
account_unlocktimeout
¶
-
auth
¶
-
auth_enablelocalconf
¶
-
authdir
¶
-
blockchain
¶
-
blockchain_coinbaseaccount
¶
-
blockchain_forceresetheight
¶
-
blockchain_maxanchorcount
¶
-
blockchain_maxblocksize
¶
-
blockchain_statetrace
¶
-
blockchain_verifiercount
¶
-
blockchain_verifyonly
¶
-
blockchain_zerofee
¶
-
conf
¶
-
consensus
¶
-
consensus_blockinterval
¶
-
consensus_enablebp
¶
-
consensus_raft
¶
-
datadir
¶
-
dbtype
¶
-
enableprofile
¶
-
enabletestmode
¶
-
mempool
¶
-
mempool_dumpfilepath
¶
-
mempool_enablefadeout
¶
-
mempool_fadeoutperiod
¶
-
mempool_showmetrics
¶
-
mempool_verifiers
¶
-
monitor
¶
-
monitor_endpoint
¶
-
monitor_protocol
¶
-
p2p
¶
-
p2p_logfullpeerid
¶
-
p2p_netprotocoladdr
¶
-
p2p_netprotocolport
¶
-
p2p_npaddpeers
¶
-
p2p_npaddpolarises
¶
-
p2p_npbindaddr
¶
-
p2p_npbindport
¶
-
p2p_npcert
¶
-
p2p_npdiscoverpeers
¶
-
p2p_npexposeself
¶
-
p2p_npkey
¶
-
p2p_npmaxpeers
¶
-
p2p_nppeerpool
¶
-
p2p_nptls
¶
-
p2p_npusepolaris
¶
-
personal
¶
-
polaris
¶
-
polaris_allowprivate
¶
-
polaris_genesisfile
¶
-
profileport
¶
-
rpc
¶
-
rpc_netserviceaddr
¶
-
rpc_netserviceport
¶
-
rpc_netservicetrace
¶
-
rpc_nsallowcors
¶
-
rpc_nscacert
¶
-
rpc_nscert
¶
-
rpc_nskey
¶
-
rpc_nstls
¶
-
usetestnet
¶
-
aergo.herapy.obj.block module¶
-
class
aergo.herapy.obj.block.
Block
(hash_value: Union[aergo.herapy.obj.block_hash.BlockHash, str, bytes, None] = None, height: Optional[int] = None, grpc_block=None, grpc_block_header=None, tx_cnt: int = 0, size: int = 0)[source]¶ Bases:
object
-
block_no
¶
-
blocks_root_hash
¶
-
chain_id
¶
-
chain_id_hash
¶
-
chain_id_hash_b58
¶
-
coinbase_account
¶
-
confirms
¶
-
datetimestamp
¶
-
hash
¶
-
height
¶
-
num_of_tx
¶
-
prev
¶
-
public_key
¶
-
receipts_root_hash
¶
-
sign
¶
-
size
¶
-
timestamp
¶
-
tx_list
¶
-
txs_root_hash
¶
-
aergo.herapy.obj.block_hash module¶
aergo.herapy.obj.block_meta_stream module¶
aergo.herapy.obj.block_stream module¶
aergo.herapy.obj.blockchain_info module¶
aergo.herapy.obj.blockchain_status module¶
aergo.herapy.obj.call_info module¶
aergo.herapy.obj.chain_id module¶
aergo.herapy.obj.change_conf_info module¶
aergo.herapy.obj.consensus_info module¶
aergo.herapy.obj.event module¶
aergo.herapy.obj.event_stream module¶
aergo.herapy.obj.name_info module¶
aergo.herapy.obj.node_info module¶
aergo.herapy.obj.peer module¶
aergo.herapy.obj.private_key module¶
-
class
aergo.herapy.obj.private_key.
PrivateKey
(pk: Union[str, bytes, None])[source]¶ Bases:
object
-
address
¶
-
asymmetric_decrypt_msg
(address: Union[str, aergo.herapy.obj.address.Address], enc_msg: Union[str, bytes]) → bytes[source]¶
-
asymmetric_encrypt_msg
(address: Union[str, aergo.herapy.obj.address.Address], msg: Union[str, bytes]) → str[source]¶
-
public_key
¶
-
aergo.herapy.obj.sc_state module¶
-
class
aergo.herapy.obj.sc_state.
SCState
(account: aergo.herapy.account.Account, var_proofs: aergo.herapy.obj.var_proof.VarProofs)[source]¶ Bases:
object
SCState holds the inclusion/exclusion proofs of a contract state in the global trie and of a variable’s value in the contract trie. SCState is returned by aergo.query_sc_state() for easy merkle proof verification give a root.
-
account
¶
-
var_proofs
¶
-
-
class
aergo.herapy.obj.sc_state.
SCStateVar
(var_name: str, array_index: Optional[int] = None, map_key: Optional[str] = None, empty: bool = False)[source]¶ Bases:
object
SCStateVar represents each variable of a calling smart contract. If the variable is the ‘state.var’ type, you can skip ‘array_index’ and ‘map_key’. If the variable is the ‘state.array’ type, use ‘array_index’ with the index number. If the variable is the ‘state.map’ type, use ‘map_key’ with the key name of the map.
aergo.herapy.obj.stream module¶
aergo.herapy.obj.transaction module¶
Transaction class.
-
class
aergo.herapy.obj.transaction.
Transaction
(from_address: Union[bytes, aergo.herapy.obj.address.Address, None] = None, to_address: Union[bytes, aergo.herapy.obj.address.Address, None] = None, nonce: int = 0, amount: Union[bytes, str, int, float] = 0, payload: Optional[bytes] = None, gas_price: int = 0, gas_limit: int = 0, read_only: bool = False, tx_hash: Optional[bytes] = None, tx_sign: Union[bytes, str, None] = None, tx_type=<TxType.TRANSFER: 4>, chain_id: Optional[bytes] = None, block=None, index_in_block: int = -1, is_in_mempool: bool = False)[source]¶ Bases:
object
Transaction data structure.
-
amount
¶
-
block
¶
-
chain_id
¶
-
from_address
¶
-
gas_limit
¶
-
gas_price
¶
-
index_in_block
¶
-
is_in_mempool
¶
-
nonce
¶
-
payload
¶
-
payload_str
¶
-
sign
¶
-
sign_str
¶
-
to_address
¶
-
tx_hash
¶
-
tx_type
¶
-
aergo.herapy.obj.tx_hash module¶
aergo.herapy.obj.tx_result module¶
aergo.herapy.obj.var_proof module¶
-
class
aergo.herapy.obj.var_proof.
VarProofs
(var_proofs, storage_keys: List[bytes])[source]¶ Bases:
list
VarProof holds the inclusion/exclusion proof of a variable state inside a contract state trie
-
storage_keys
¶
-
var_proofs
¶
-
Module contents¶
aergo.herapy.status package¶
Submodules¶
aergo.herapy.status.commit_status module¶
Enumeration of Commit Status.
-
class
aergo.herapy.status.commit_status.
CommitStatus
[source]¶ Bases:
enum.IntEnum
TX_OK = 0 TX_NONCE_TOO_LOW = 1 TX_ALREADY_EXISTS = 2 TX_INVALID_HASH = 3 TX_INVALID_SIGN = 4 TX_INVALID_FORMAT = 5 TX_INSUFFICIENT_BALANCE = 6 TX_HAS_SAME_NONCE = 7 TX_INTERNAL_ERROR = 9
-
TX_ALREADY_EXISTS
= 2¶
-
TX_HAS_SAME_NONCE
= 7¶
-
TX_INSUFFICIENT_BALANCE
= 6¶
-
TX_INTERNAL_ERROR
= 9¶
-
TX_INVALID_FORMAT
= 5¶
-
TX_INVALID_HASH
= 3¶
-
TX_INVALID_SIGN
= 4¶
-
TX_NONCE_TOO_LOW
= 1¶
-
TX_OK
= 0¶
-
aergo.herapy.status.peer_status module¶
Enumeration of Smart contract Status.
aergo.herapy.status.tx_result_status module¶
Enumeration of Smart contract Status.
Module contents¶
aergo.herapy.utils package¶
Submodules¶
aergo.herapy.utils.converter module¶
Common utility module for converting types.
-
aergo.herapy.utils.converter.
convert_aergo_conf_to_toml
(aergo_conf: aergo.herapy.obj.aergo_conf.AergoConfig) → str[source]¶
-
aergo.herapy.utils.converter.
convert_bytes_to_public_key
(v: bytes, curve: ecdsa.curves.Curve = SECP256k1) → ecdsa.ecdsa.Public_key[source]¶
-
aergo.herapy.utils.converter.
convert_public_key_to_bytes
(pubkey, curve=SECP256k1, compressed=True) → bytes[source]¶
-
aergo.herapy.utils.converter.
convert_toml_to_aergo_conf
(v: str) → aergo.herapy.obj.aergo_conf.AergoConfig[source]¶
-
aergo.herapy.utils.converter.
get_hash
(*strings, no_rand: bool = False, no_encode: bool = False) → Union[str, bytes, None][source]¶
aergo.herapy.utils.encoding module¶
-
aergo.herapy.utils.encoding.
decode_private_key
(private_key: Optional[str]) → Optional[bytes][source]¶
-
aergo.herapy.utils.encoding.
decode_tx_hash
(tx_hash: Union[str, bytes, None]) → Optional[bytes][source]¶
aergo.herapy.utils.merkle_proof module¶
-
aergo.herapy.utils.merkle_proof.
verify_exclusion
(root: bytes, ap: List[bytes], key: bytes, proofKey: bytes, proofVal: bytes) → bool[source]¶ verify_exclusion verifies the merkle proof that a default node (bytes([0]) is included on the path of the ‘key’, or that the proofKey/proofVal key pair is included on the path of the ‘key’
-
aergo.herapy.utils.merkle_proof.
verify_exclusion_c
(root: bytes, ap: List[bytes], length: int, bitmap: bytes, key: bytes, proofKey: bytes, proofVal: bytes) → bool[source]¶ verify_exclusion_c verifies the compressed merkle proof that a default node (bytes([0]) is included on the path of the ‘key’, or that the proofKey/proofVal key pair is included on the path of the ‘key’
-
aergo.herapy.utils.merkle_proof.
verify_inclusion
(ap: List[bytes], root: bytes, key: bytes, value: bytes) → bool[source]¶ verify_inclusion verifies the merkle proof ‘ap’ (audit path) that the key/value pair in included in the trie with root ‘root’.
-
aergo.herapy.utils.merkle_proof.
verify_inclusion_c
(ap: List[bytes], height: int, bitmap: bytes, root: bytes, key: bytes, value: bytes) → bool[source]¶ verify_inclusion verifies the compressed merkle proof ‘ap’ (audit path) that the key/value pair in included in the trie with root ‘root’.
aergo.herapy.utils.signature module¶
-
aergo.herapy.utils.signature.
uncompress_key
(compressed_key_hex)[source]¶ base source : https://stackoverflow.com/questions/43629265/deriving-an- ecdsa-uncompressed-public-key-from-a-compressed-one?rq=1 The code from bitcointalk sometimes produces a hex string uncompressed key of uneven length.
Module contents¶
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
¶
-
sql_recovery_point
¶
-
state
¶
-
state_proof
¶
-
storage_root
¶
-
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]¶
-
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_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_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_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]¶
-
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]¶
-
del_raft_member
(request_id: int, member_id: int, member_name: str, member_address: str, member_peer_id: bytes)[source]¶
-
get_block_headers
(block_hash: Optional[bytes], block_height: int, list_size: int, offset: int, is_asc_order: bool)[source]¶
-
get_block_metas
(block_hash: Optional[bytes], block_height: int, list_size: int, offset: int, is_asc_order: bool)[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]¶
-
query_contract_state
(sc_address: bytes, storage_keys: List[bytes], root: bytes, compressed: bool)[source]¶
-
aergo.herapy.constants module¶
Module contents¶
Top-level package for herapy.