ApiService class

A service class for interacting with the Archethic API.

This class provides methods to interact with the Archethic blockchain, including querying tokens, managing exceptions, and handling retries.

Constructors

ApiService(String endpoint, {int maxRetries = 5, Duration retryDelay(int retryCount) = _defaultRetryDelay})
Creates an instance of ApiService.

Properties

endpoint String
HTTP URL to a Archethic node (acting as welcome node)
final
hashCode int
The hash code for this object.
no setterinherited
maxRetries int
The maximum number of retries for failed requests.
final
retryDelay Duration Function(int retryCount)
A function that calculates the delay between retries.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addOriginKey({String? originPublicKey, String? certificate}) Future<String>
Add a new origin key
callSCFunction({required SCCallFunctionRequest jsonRPCRequest, bool resultMap = false}) Future<Object>
Call a smart contract's function.
callSCFunctionMulti({required List<SCCallFunctionRequest> jsonRPCRequests}) Future<List>
Call a smart contract's function
chainUnspentOutputs(List<String> genesisAddresses, {String request = Transaction.kUnspentOutputQueryFieldsWithoutState, int limit = 0, String pagingOffset = ''}) Future<Map<String, List<UnspentOutputs>>>
Query the network to retrieve the unspent output of a chain (address should be the genesis address of the chain)
fetchBalance(List<String> addresses, {String request = Transaction.kBalanceQueryAllFields}) Future<Map<String, Balance>>
Query the network to find a balance from a list of addresses
getBlockchainVersion() Future<BlockchainVersionModel>
Query the network to find the protocol, transaction and code versions
getGenesisAddress(String address) Future<Address>
Query the network to find the genesis address of a transaction
getJsonRPCResult(String body) → dynamic
inherited
getJsonRPCResultString(String body) String
inherited
getKeychain(String seed) Future<Keychain>
Retrieve a keychain by using keychain access seed
getLastTransaction(List<String> addresses, {String request = Transaction.kTransactionQueryAllFields}) Future<Map<String, Transaction>>
Query the network to find the last transaction from a list of addresses
getNearestEndpoints() Future<List<Endpoint>>
List the nearest endpoints nodes from the client's IP
getNodeList() Future<List<Node>>
Query the node infos
getOriginKey() String
getStorageNoncePublicKey() Future<String>
getToken(List<String> addresses, {String request = 'genesis, name, id, supply, symbol, type, properties, decimals, collection, ownerships { authorizedPublicKeys { encryptedSecretKey, publicKey }, secret }'}) Future<Map<String, Token>>
Query the network to find a token's data from a list of token addresses
getTransaction(List<String> addresses, {String request = Transaction.kTransactionQueryAllFields}) Future<Map<String, Transaction>>
Query the network to find a transaction.
getTransactionChain(Map<String, String> addresses, {String request = Transaction.kTransactionQueryAllFields, bool orderAsc = true, int? fromCriteria}) Future<Map<String, List<Transaction>>>
Query the network to find transaction chains from a map of addresses and pagingAddress
getTransactionContent(List<String> addresses) Future<Map<String, String>>
Query the network to find a transaction from a list of addresses
getTransactionFee(Transaction transaction) Future<TransactionFee>
Get transaction fees
getTransactionIndex(List<String> addresses) Future<Map<String, int>>
getTransactionInputs(List<String> addresses, {String request = Transaction.kTransactionInputQueryAllFields, int limit = 0, int pagingOffset = 0}) Future<Map<String, List<TransactionInput>>>
Query the network to list the transaction inputs from a list of addresses
getTransactionOwnerships(List<String> addresses) Future<Map<String, List<Ownership>>>
getTransactionOwnerships
manageLinkException(QueryResult<Object?> result) → void
Handles exceptions from a QueryResult.
networkTransactions(String type, int page, {String request = Transaction.kTransactionQueryAllFields}) Future<List<Transaction>>
Query the network to list the transaction on the type.
newAccessKeychainTransaction(String seed, Uint8List keychainAddress, Uint8List originPrivateKey, int blockchainTxVersion) Transaction
Create a new access keychain and build a transaction
newKeychainTransaction(String seed, List<String> authorizedPublicKeys, Uint8List originPrivateKey, int blockchainTxVersion, {Map<String, String>? servicesMap}) Transaction
Create a new keychain and build a transaction
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sendTx(Transaction transaction) Future<TransactionStatus>
Send a transaction to the network
setJsonRPCRequest(String method, Object params, {int id = 1}) String
inherited
toString() String
A string representation of this object.
inherited
withRetry<T>({required Future<T> action(), required String actionName, int maxRetries = 5, Duration retryDelay(int retryCount) = _defaultRetryDelay}) Future<T>
Executes an action with retry logic.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

kRequestHeaders → const Map<String, String>