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<GrpcBlockchainStatus.AsObject> – an object detailing the current status
-
AergoClient.
defaultProvider
()¶ Returns: any –
-
AergoClient.
getABI
(address)¶ Query contract ABI
Arguments: - address (any) – of contract
Returns: any – abi
-
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/index.BlockBodyPaged> –
-
AergoClient.
getBlockHeaders
(hashOrNumber, size, offset, desc)¶ Retrieve the last n blocks, beginning from given block .
Arguments: - hashOrNumber (any) – 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) –
- desc (boolean) –
Returns: any – 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: <TODO> –
-
AergoClient.
getBlockStream
()¶ Returns: client/index.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 (string) – 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: object –
-
AergoClient.
getConsensusInfo
()¶ Return consensus info. The included fields can differ by consensus type.
Returns: Promise<client/index.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/index.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 (any) –
Returns: Promise<client/index.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)¶ Arguments: - address (any) –
Returns: Promise<number> –
-
AergoClient.
getPeers
(showself, showhidden)¶ Get list of peers of connected node
Arguments: - showself (boolean) –
- showhidden (boolean) –
Returns: any –
-
AergoClient.
getServerInfo
(keys)¶ Return server info
Arguments: - keys (string[]) –
Returns: Promise<client/index.ServerInfoResult> –
-
AergoClient.
getStaking
(address)¶ Return information for account name
Arguments: - address (any) – Account address encoded in Base58check
Returns: any –
-
AergoClient.
getState
(address)¶ Retrieve account state, including current balance and nonce.
Arguments: - address (any) – Account address encoded in Base58check
Returns: Promise<models/state.State> – account state
-
AergoClient.
getTopVotes
(count, id)¶ Return the top voted-for block producer
Arguments: - count (number) – number
- id (string) –
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 (any) – transaction hash
Returns: Promise<client/index.GetTxResult> – transaction details, object of tx: <Tx> and block: { hash, idx }
-
AergoClient.
getTransactionReceipt
(txhash)¶ Retrieve the transaction receipt for a transaction
Arguments: - txhash (any) – transaction hash
Returns: Promise<client/index.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: 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/index.JsonData|client/index.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.
setProvider
(provider)¶ Set a new provider
Arguments: - provider (any) –
-
AergoClient.
verifyTransaction
()¶ Returns: any –
-
AergoClient.
defaultProviderClass
¶ type: <TODO>
-
AergoClient.
platform
¶ type: string