ain.ain module
- class ain.ain.Ain(providerUrl: str, chainId: int = 0, ainOptions: ~ain.types.AinOptions = <ain.types.AinOptions object>)
Bases:
object
Class for the Ain instance, the interactor for the AIN Blockchain.
- Parameters:
providerUrl (str) – The URL of the provider, the listening blockchain node.
chainId (int) – The chain ID of the provider. Defaults to 0.
ainOptions (AinOptions) – The options for this Ain instance. Defaults to no options.
- depositConsensusStake(input: ValueOnlyTransactionInput) Any
Sends a transaction that deposits AIN for consensus staking.
- Parameters:
input (ValueOnlyTransactionInput) – The value only transaction input to deposit AIN value.
- Returns:
The transaction results.
- async getBlockByHash(blockHash: str, returnTransactionObjects: bool = False) Any
Gets a block with the given block hash.
- Parameters:
blockHash (str) – The block hash.
returnTransactionObjects (bool) – If True, returns the full transaction objects. If False, returns only the transaction hashes. Default to False.
- Returns:
The block with the given block hash.
- async getBlockByNumber(blockNumber: int, returnTransactionObjects: bool = False) Any
Gets a block with the given block number.
- Parameters:
blockNumber (int) – The block number.
returnTransactionObjects (bool) – If True, returns the full transaction objects. If False, returns only the transaction hashes. Default to False.
- Returns:
The block with the given block number.
- async getBlockHeadersList(begin: int, end: int) List[Any]
Fetches block headers with a block number range.
- Parameters:
begin (int) – The begining block number (inclusive).
end (int) – The ending block number (exclusive).
- Returns:
The block headers list.
- async getBlockList(begin: int, end: int) List[Any]
“Fetches blocks with a block number range.
- Parameters:
begin (int) – The begining block number (inclusive).
end (int) – The ending block number (exclusive).
- Returns:
The block list.
- async getBlockTransactionCountByHash(blockHash: str) int
Fetches block transaction count with a block hash.
- Parameters:
blockHash (str) – The block hash.
- Returns:
The block transaction count.
- async getBlockTransactionCountByNumber(blockNumber: int) int
Fetches block transaction count with a block number.
- Parameters:
blockNumber (int) – The block number.
- Returns:
The block transaction count.
- async getConsensusStakeAmount(account: str = None) Any
Gets an amount of the AIN currently staked for participating in consensus protocol.
- Parameters:
Account (str, Optional) – The address of the consensus participant.
- Returns:
The amount of the AIN of that address.
- async getLastBlock() Any
Fetches the last block.
Args:
- Returns:
The last block.
- async getLastBlockNumber() int
Fetches the last block number.
Args:
- Returns:
The last block number.
- async getPendingTransactions() Any
Fetches pending transactions.
Args:
- Returns:
The pending transactions.
- async getProposerByHash(blockHash: str) str
Fetches the block proproser’s address of a block with a block hash.
- Parameters:
blockHash (str) – The block hash.
- Returns:
The address of the proposer of the given block.
- async getProposerByNumber(blockNumber: int) str
Fetches the block proproser’s address of a block with a block number.
- Parameters:
blockNumber (int) – The block number.
- Returns:
The address of the proposer of the given block.
- async getStateUsage(appName: str) Any
Gets a state usage with the given app name.
- Parameters:
appName (str) – The app name;
- Returns:
The state usage with the given app name.
- async getTransactionByBlockHashAndIndex(blockHash: str, index: int) Any
Fetches a transaction’s information with a block hash and an index.
- Parameters:
blockHash (str) – The block hash.
index (int) – The transaction index in the block
- Returns:
The transaction with the given parameter values.
- async getTransactionByBlockNumberAndIndex(blockNumber: int, index: int) Any
Fetches a transaction’s information with a block number and an index.
- Parameters:
blockHash (int) – The block number.
index (int) – The transaction index in the block
- Returns:
The transaction with the given parameter values.
- async getTransactionByHash(transactionHash: str) Any
Gets a transaction with the given transaction hash.
- Parameters:
transactionHash (str) – The transaction hash.
- Returns:
The transaction with the given transaction hash.
- async getTransactionPoolSizeUtilization() Any
Fetches transaction pool size utilization.
Args:
- Returns:
The transaction pool size utilization.
- async getValidatorInfo(address: str) Any
Fetches the information of the given validator address.
- Parameters:
address (str) – The block number.
- Returns:
The validator information.
- async getValidatorsByHash(blockHash: str) Any
Fetches the validator list of a block with a block hash.
- Parameters:
blockHash (str) – The block hash.
- Returns:
The list of validators of the given block.
- async getValidatorsByNumber(blockNumber: int) Any
Fetches the validator list of a block with a block number.
- Parameters:
blockNumber (int) – The block number.
- Returns:
The list of validators of the given block.
- async sendSignedTransaction(signature: str, txBody: TransactionBody, isDryrun=False) Any
Sends a signed transaction to the network.
- Parameters:
signature (str) – The signature.
txBody (TransactionBody) – The transaction body.
isDryrun (bool) – The dryrun option.
- Returns:
The return value of the blockchain API.
- async sendTransaction(transactionObject: TransactionInput, isDryrun=False) Any
Signs and sends a transaction to the network.
- Parameters:
transactionObject (TransactionInput) – The transaction input object.
isDryrun (bool) – The dryrun option.
- Returns:
The return value of the blockchain API.
- async sendTransactionBatch(transactionObjects: List[TransactionInput]) List[Any]
Signs and sends multiple transactions in a batch to the network.
- Parameters:
transactionObjects (List[TransactionInput]) – The list of the transaction input objects.
- Returns:
The return value of the blockchain API.
- setProvider(providerUrl: str, chainId: int = 0)
Sets a new provider
- Parameters:
providerUrl (str) – The URL of the new provider.
chainId (int) – The chain ID of the new provider. Defaults to 0.
- setSigner(signer: Signer)
Sets a new signer
- Parameters:
signer (Signer) – The signer to set.
- async validateAppName(appName: str) Any
Validate a given app name.
- Parameters:
appName (str) – The app name;
- Returns:
The validity of the given app name.
- withdrawConsensusStake(input: ValueOnlyTransactionInput) Any
Sends a transaction that withdraws AIN for consensus staking.
- Parameters:
input (ValueOnlyTransactionInput) – The value only transaction input to withdraw AIN value.
- Returns:
The transaction results.
- chainId: int
The chain ID of the provider.
- rawResultMode: bool
The flag of the raw result mode.
- signer: Signer
The Signer instance.