5. API Modules
Complete reference for all API modules in the Amadeus Protocol SDK.
Overview
The SDK provides access to various API modules through the AmadeusSDK instance:
import { AmadeusSDK } from '@amadeus-protocol/sdk'
const sdk = new AmadeusSDK()
// Access API modules
sdk.chain // Chain API
sdk.wallet // Wallet API
sdk.transaction // Transaction API
sdk.contract // Contract API
sdk.epoch // Epoch API
sdk.peer // Peer API
sdk.proof // Proof APIChain API
Query blockchain data including chain tip, statistics, entries, and transaction events.
getTip()
Get the current chain tip (latest entry).
Returns: Promise<GetTipResponse> with chain entry
getStats()
Get chain statistics.
Returns: Promise<GetStatsResponse> with chain statistics
getByHeight(height: number)
Get entries at a specific height.
Parameters:
height(number): Chain height
Returns: Promise<GetByHeightResponse> with array of entries
getByHash(hash: string)
Get entries by hash.
Parameters:
hash(string): Entry hash (Base58 encoded)
Returns: Promise<GetByHashResponse> with chain entry
getTransactionEventsByAccount(address: string, filters?: TransactionFilters)
Get transaction events for an account.
Parameters:
address(string): Account address (Base58 encoded)filters(optional): Transaction filters
Returns: Promise<GetTransactionEventsByAccountResponse> with transaction events
Wallet API
Query wallet balances and transaction information.
getBalance(address: string, symbol?: string)
Get balance for a specific address and token symbol.
Parameters:
address(string): Wallet address (Base58 encoded)symbol(string, optional): Token symbol (default: 'AMA')
Returns: Promise<WalletBalance> with token balance
getAllBalances(address: string)
Get all token balances for an address.
Parameters:
address(string): Wallet address (Base58 encoded)
Returns: Promise<GetAllBalancesResponse> with all balances
getTransactions(address: string, query?: GetWalletTransactionsQuery)
Get transactions for a wallet address.
Parameters:
address(string): Wallet address (Base58 encoded)query(optional): Query parameters (limit, sort, contract, function, type, cursor)
Returns: Promise<GetWalletTransactionsResponse> with transactions and cursor
Transaction API
Submit transactions and query transaction data.
submit(txPacked: Uint8Array | string)
Submit a transaction to the network.
Parameters:
txPacked(Uint8Array | string): Packed transaction as Uint8Array or Base58 string
Returns: Promise<SubmitTransactionResponse> with submission result
submitAndWait(txPacked: Uint8Array | string)
Submit a transaction and wait for confirmation.
Parameters:
txPacked(Uint8Array | string): Packed transaction
Returns: Promise<SubmitAndWaitTransactionResponse> with confirmation result
get(txHash: string)
Get a transaction by hash.
Parameters:
txHash(string): Transaction hash (Base58 encoded)
Returns: Promise<Transaction> with transaction data
getTransactionsInEntry(entryHash: string)
Get all transactions in a specific entry.
Parameters:
entryHash(string): Entry hash (Base58 encoded)
Returns: Promise<GetTransactionsInEntryResponse> with transactions
Contract API
Interact with smart contracts and query contract data.
get(key: Uint8Array | string)
Get contract data by key.
Parameters:
key(Uint8Array | string): Contract key as Uint8Array or Base58 string
Returns: Promise<ContractDataValue> with contract data
getPrefix(key: Uint8Array | string)
Get contract data by key prefix.
Parameters:
key(Uint8Array | string): Contract key prefix
Returns: Promise<ContractDataValue[]> with array of key-value pairs
validateBytecode(bytecode: Uint8Array | ArrayBuffer)
Validate contract bytecode.
Parameters:
bytecode(Uint8Array | ArrayBuffer): Contract bytecode to validate
Returns: Promise<ValidateBytecodeResponse> with validation result
getRichlist()
Get contract richlist (token holders).
Returns: Promise<GetRichlistResponse> with richlist entries
Epoch API
Query epoch and validator data.
getScore(publicKey?: string)
Get epoch score(s).
Parameters:
publicKey(string, optional): Validator public key (Base58 encoded)
Returns: Promise<EpochScore | EpochScore[]> with score(s)
getAllScores()
Get all epoch scores.
Returns: Promise<EpochScore[]> with all scores
getTopValidators(limit: number)
Get top validators by score.
Parameters:
limit(number): Number of top validators to return
Returns: Promise<EpochScore[]> with top validators
getEmissionAddress()
Get the current emission address.
Returns: Promise<GetEmissionAddressResponse> with emission address
getSolInEpoch(epoch: number, solutionHash: string)
Check if a solution is in a specific epoch.
Parameters:
epoch(number): Epoch numbersolutionHash(string): Solution hash (Base58 encoded)
Returns: Promise<GetSolInEpochResponse> with check result
Peer API
Query network peer information.
getNodes()
Get all network nodes.
Returns: Promise<PeerInfo[]> with node information
getTrainers()
Get all trainers.
Returns: Promise<PeerInfo[]> with trainer information
getRemovedTrainers()
Get removed trainers.
Returns: Promise<PeerInfo[]> with removed trainer information
getANRs()
Get ANR (Autonomous Network Registry) entries.
Returns: Promise<ANRInfo[]> with ANR information
getANRByPk(publicKey: string)
Get ANR entry by public key.
Parameters:
publicKey(string): Public key (Base58 encoded)
Returns: Promise<ANRInfo> with ANR information
Proof API
Query validator proofs.
getValidators(entryHash: string)
Get validator proof for an entry.
Parameters:
entryHash(string): Entry hash (Base58 encoded)
Returns: Promise<ProofValidators> with validator proof
Error Handling
All API methods throw AmadeusSDKError on failure:
Next Steps
Last updated