AergoClient¶
-
class
AergoClient
(config, provider)¶ exported from
client/index
Main aergo client controller.
Create a new auto-configured client with:
import AergoClient from '@herajs/client'; const aergo = new AergoClient();
Arguments: - config (<TODO>) –
- provider (any) –
-
AergoClient.
accounts
¶ type: accounts/index.Accounts
-
AergoClient.
client
¶ type: any
-
AergoClient.
config
¶ type: object
-
AergoClient.
target
¶ type: string
-
AergoClient.
blockchain
()¶ Request current status of blockchain.
Returns: Promise<client/types.BlockchainResult> – an object detailing the current status
-
AergoClient.
defaultProvider
()¶ Returns: any –
-
AergoClient.
getABI
(address)¶ Query contract ABI
Arguments: - address (models/address.AddressInput) – of contract
Returns: Promise<models/contract.Abi> – abi
-
AergoClient.
getAccountVotes
(address)¶ Return the top voted-for block producer or system parameter
Arguments: - address (models/address.AddressInput) – string
Returns: Promise<any> –
-
AergoClient.
getBlock
(hashOrNumber)¶ Retrieve information about a block.
Arguments: - hashOrNumber (string|number) – either 32-byte block hash encoded as a bs58 string or block height as a number.
Returns: Promise<models/block.Block> – block details
-
AergoClient.
getBlockBody
(hashOrNumber, offset, size)¶ Get the transactions of a block in a paged manner
Arguments: - hashOrNumber (string|number) –
- offset (number) –
- size (number) –
Returns: Promise<client/types.BlockBodyPaged> –
-
AergoClient.
getBlockHeaders
(hashOrNumber, size, offset, desc)¶ Retrieve the last n blocks, beginning from given block
Arguments: - hashOrNumber (string|number) – either 32-byte block hash encoded as a bs58 string or block height as a number.
- size (number) – number of blocks to return
- offset (number) – number of blocks to skip
- desc (boolean) – order of blocks
Returns: Promise<models/block.Block[]> – list of block headers (blocks without body)
-
AergoClient.
getBlockMetadata
(hashOrNumber)¶ Retrieve block metadata (excluding body).
Arguments: - hashOrNumber (string|number) – either 32-byte block hash encoded as a bs58 string or block height as a number.
Returns: Promise<models/blockmetadata.BlockMetadata> – block metadata
-
AergoClient.
getBlockMetadataStream
()¶ Returns a stream of block metadata
Returns: client/types.Stream<models/blockmetadata.BlockMetadata> –
-
AergoClient.
getBlockStream
()¶ Returns: client/types.Stream<models/block.Block> –
-
AergoClient.
getChainIdHash
(enc)¶ Request chain id hash. This automatically gathers the chain id hash from the current node if not specified.
Arguments: - enc (utils.ByteEncoding) – set to ‘base58’ to retrieve the hash encoded in base58. Otherwise returns a Uint8Array.
Returns: Promise<Uint8Array|string> – Uint8Array by default, base58 encoded string if enc = ‘base58’.
-
AergoClient.
getChainInfo
()¶ Request current status of blockchain.
Returns: Promise<models/chaininfo.ChainInfo> – an object detailing the current status
-
AergoClient.
getConfig
()¶ Returns: any –
-
AergoClient.
getConsensusInfo
()¶ Return consensus info. The included fields can differ by consensus type.
Returns: Promise<client/types.ConsensusInfoResult> –
-
AergoClient.
getEventStream
(filter)¶ Returns a stream that yields new events matching the specified filter in real-time.
const stream = aergo.getEventStream({ address: 'Am....' }); stream.on('data', (event) => { console.log(event); stream.cancel(); });
Arguments: - filter (Partial<models/filterinfo.FilterInfo>) –
FilterInfo()
Returns: client/types.Stream<models/event.Event> – event stream
- filter (Partial<models/filterinfo.FilterInfo>) –
-
AergoClient.
getEvents
(filter)¶ Query contract state This only works vor variables explicitly defines as state variables.
Arguments: - filter (Partial<models/filterinfo.FilterInfo>) –
FilterInfo()
Returns: Promise<models/event.Event[]> – list of events
- filter (Partial<models/filterinfo.FilterInfo>) –
-
AergoClient.
getNameInfo
(name)¶ Return information for account name
Arguments: - name (string) –
Returns: Promise<client/types.NameInfoResult> –
-
AergoClient.
getNodeState
(component, timeout)¶ Request current status of node.
Arguments: - component (string) –
- timeout (number) –
Returns: Promise<any> – an object detailing the state of various node components
-
AergoClient.
getNonce
(address)¶ Retrieve account’s most recenlty used nonce. This is a shortcut function as the same information is also returned by getState.
Arguments: - address (models/address.AddressInput) – Account address encoded in Base58check
Returns: Promise<number> – account state
-
AergoClient.
getPeers
(showself, showhidden)¶ Get list of peers of connected node
Arguments: - showself (boolean) –
- showhidden (boolean) –
Returns: Promise<models/peer.Peer[]> –
-
AergoClient.
getServerInfo
(keys)¶ Return server info
Arguments: - keys (string[]) –
Returns: Promise<client/types.ServerInfoResult> –
-
AergoClient.
getStaking
(address)¶ Return information for account name
Arguments: - address (models/address.AddressInput) – Account address encoded in Base58check
Returns: Promise<Staking.AsObject> –
-
AergoClient.
getState
(address)¶ Retrieve account state, including current balance and nonce.
Arguments: - address (models/address.AddressInput) – Account address encoded in Base58check
Returns: Promise<models/state.State> – account state
-
AergoClient.
getTopVotes
(count, id)¶ Return the top {count} result for a vote
Arguments: - count (number) – number
- id (string) – vote identifier, default: voteBP
Returns: Promise<any> –
-
AergoClient.
getTransaction
(txhash)¶ Get transaction information in the aergo node. If transaction is in the block return result with block hash and index.
Arguments: - txhash (string) – transaction hash
Returns: Promise<client/types.GetTxResult> – transaction details, object of tx: <Tx> and block: { hash, idx }
-
AergoClient.
getTransactionReceipt
(txhash)¶ Retrieve the transaction receipt for a transaction
Arguments: - txhash (string) – transaction hash
Returns: Promise<client/types.GetReceiptResult> – transaction receipt
-
AergoClient.
grpcMethod
(method)¶ Arguments: - method (Function) –
Returns: <TODO> –
-
AergoClient.
isConnected
()¶ Returns: boolean –
-
AergoClient.
queryContract
(functionCall)¶ Query contract ABI
Arguments: - functionCall (models/contract.FunctionCall) – call details
Returns: Promise<any> – result of query
-
AergoClient.
queryContractState
(stateQuery)¶ Query contract state. This only works for variables explicitly defines as state variables. Throws when contract do not exist, or when variable does not exist when requesting single key.
Arguments: - stateQuery (models/contract.StateQuery) – query details obtained from contract.queryState()
Returns: Promise<client/types.JsonData|models/statequeryproof.BasicType> – result of query: single value if requesting one key, list of values when requesting multiple keys.
-
AergoClient.
queryContractStateProof
(stateQuery)¶ Query contract state, including proofs. This only works vor variables explicitly defines as state variables.
Arguments: - stateQuery (models/contract.StateQuery) – query details obtained from contract.queryState()
Returns: Promise<models/statequeryproof.StateQueryProof> – result of query, including account and var proofs
-
AergoClient.
sendSignedTransaction
(tx)¶ Send a signed transaction to the network.
Arguments: - tx (any) – signed transaction
Returns: Promise<string> – transaction hash
-
AergoClient.
setChainIdHash
(hash)¶ Set the chain id hash to use for subsequent transactions.
Arguments: - hash (string|Uint8Array) – string (base58 encoded) or byte array
-
AergoClient.
setDefaultLimit
(limit)¶ Set the default gas limit to use for transactions that do not define their own.
Arguments: - limit (number) –
-
AergoClient.
setProvider
(provider)¶ Set a new provider
Arguments: - provider (any) –
-
AergoClient.
waitForTransactionReceipt
(txhash, timeout, baseBackoffInterval)¶ Retrieve the transaction receipt for a transaction, but keep retrying if not available yet. Uses expoinential backoff and a final timeout.
Arguments: - txhash (string) – transaction hash
- timeout (number) – throws error when timeout is reached
- baseBackoffInterval (number) – base time for exponentail backoff
Returns: Promise<client/types.GetReceiptResult> – transaction receipt
-
AergoClient.
defaultProviderClass
¶ type: <TODO>
-
AergoClient.
platform
¶ type: string