adamant-api / api / AdamantApi
Class: AdamantApi
Defined in: src/api/index.ts:441
Resilient client for the public ADAMANT Node HTTP API.
The client inherits node health checks and failover from the internal NodeManager and returns structured API results instead of exposing raw Axios errors.
Extends
NodeManager
Constructors
Constructor
new AdamantApi(options): AdamantApi;Defined in: src/api/index.ts:446
Parameters
| Parameter | Type |
|---|---|
options | AdamantApiOptions |
Returns
AdamantApi
Overrides
NodeManager.constructorProperties
hasCompatibleNode
protected hasCompatibleNode: boolean = true;Defined in: src/helpers/healthCheck.ts:61
Inherited from
NodeManager.hasCompatibleNodelogger
protected logger: Logger;Defined in: src/helpers/healthCheck.ts:60
Inherited from
NodeManager.loggermaxRetries
maxRetries: number;Defined in: src/api/index.ts:442
node
node: string;Defined in: src/helpers/healthCheck.ts:57
Inherited from
NodeManager.nodeoptions
options: NodeManagerOptions;Defined in: src/helpers/healthCheck.ts:55
Inherited from
NodeManager.optionssocket?
optional socket?: WebSocketClient;Defined in: src/helpers/healthCheck.ts:58
Inherited from
NodeManager.socketMethods
checkNode()
checkNode(node): Promise<
| Omit<GetNodeStatusResponseDto, "success"> & {
success: true;
}
| {
success: false;
}>;Defined in: src/helpers/healthCheck.ts:311
Parameters
| Parameter | Type |
|---|---|
node | string |
Returns
Promise< | Omit<GetNodeStatusResponseDto, "success"> & { success: true; } | { success: false; }>
Inherited from
NodeManager.checkNodecheckNodes()
checkNodes(): Promise<ActiveNode[]>;Defined in: src/helpers/healthCheck.ts:327
Returns
Promise<ActiveNode[]>
Inherited from
NodeManager.checkNodeschooseNode()
chooseNode(activeNodes, forceChangeActiveNode?): Promise<void>;Defined in: src/helpers/healthCheck.ts:151
Parameters
| Parameter | Type |
|---|---|
activeNodes | ActiveNode[] |
forceChangeActiveNode? | boolean |
Returns
Promise<void>
Inherited from
NodeManager.chooseNodecreateAccount()
createAccount(publicKey): Promise<
| {
errorMessage: string;
success: boolean;
}
| Omit<CreateNewAccountResponseDto, "success"> & {
success: true;
}>;Defined in: src/api/index.ts:580
Initializes an account from a public key without transmitting a secret.
Parameters
| Parameter | Type |
|---|---|
publicKey | string |
Returns
Promise< | { errorMessage: string; success: boolean; } | Omit<CreateNewAccountResponseDto, "success"> & { success: true; }>
get()
get<T>(endpoint, params?): Promise<AdamantApiResult<T>>;Defined in: src/api/index.ts:537
Makes GET request to ADAMANT network.
endpoint should be in 'accounts/getPublicKey' format, excluding '/api/'.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
endpoint | string |
params? | unknown |
Returns
Promise<AdamantApiResult<T>>
getAccountBalance()
getAccountBalance(address): Promise<AdamantApiResult<GetAccountBalanceResponseDto>>;Defined in: src/api/index.ts:892
Get account balance
Parameters
| Parameter | Type |
|---|---|
address | string |
Returns
Promise<AdamantApiResult<GetAccountBalanceResponseDto>>
getAccountInfo()
getAccountInfo(options): Promise<AdamantApiResult<GetAccountInfoResponseDto>>;Defined in: src/api/index.ts:883
Get account information by ADAMANT address or Public Key
Parameters
| Parameter | Type |
|---|---|
options | AddressOrPublicKeyObject |
Returns
Promise<AdamantApiResult<GetAccountInfoResponseDto>>
getBlock()
getBlock(id): Promise<AdamantApiResult<GetBlockInfoResponseDto>>;Defined in: src/api/index.ts:911
Get block information by ID
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Promise<AdamantApiResult<GetBlockInfoResponseDto>>
getBlocks()
getBlocks(options?): Promise<AdamantApiResult<GetBlocksResponseDto>>;Defined in: src/api/index.ts:918
Get list of blocks
Parameters
| Parameter | Type |
|---|---|
options? | GetBlocksOptions |
Returns
Promise<AdamantApiResult<GetBlocksResponseDto>>
getBroadhash()
getBroadhash(): Promise<AdamantApiResult<GetBroadhashResponseDto>>;Defined in: src/api/index.ts:1098
Broadhash is established as an aggregated rolling hash of the past five blocks present in the database.
Returns
Promise<AdamantApiResult<GetBroadhashResponseDto>>
getChatMessages()
getChatMessages(
address1,
address2,
query?): Promise<AdamantApiResult<GetChatMessagesResponseDto>>;Defined in: src/api/index.ts:939
Get messages between two accounts
Parameters
| Parameter | Type |
|---|---|
address1 | string |
address2 | string |
query? | TransactionQuery<ChatroomsOptions> |
Returns
Promise<AdamantApiResult<GetChatMessagesResponseDto>>
getChats()
getChats(address, options?): Promise<AdamantApiResult<GetChatRoomsResponseDto>>;Defined in: src/api/index.ts:925
Get list of Chats
Parameters
| Parameter | Type |
|---|---|
address | string |
options? | TransactionQuery<ChatroomsOptions> |
Returns
Promise<AdamantApiResult<GetChatRoomsResponseDto>>
getChatTransactions()
getChatTransactions(options?): Promise<AdamantApiResult<GetChatTransactionsResponseDto>>;Defined in: src/api/index.ts:955
Gets chat transactions through the legacy /api/chats/get endpoint.
Parameters
| Parameter | Type |
|---|---|
options? | TransactionQuery<ChatroomsOptions> |
Returns
Promise<AdamantApiResult<GetChatTransactionsResponseDto>>
Deprecated
Use getChats or getChatMessages instead.
getDelegate()
getDelegate(options): Promise<AdamantApiResult<GetDelegateResponseDto>>;Defined in: src/api/index.ts:979
Gets delegate info by username, publicKey, or address.
The delegate includes forged, the lifetime sum of block fees and rewards as a base-10 integer string in base units.
Parameters
| Parameter | Type |
|---|---|
options | DelegateLookupOptions |
Returns
Promise<AdamantApiResult<GetDelegateResponseDto>>
getDelegates()
getDelegates(options?): Promise<AdamantApiResult<GetDelegatesResponseDto>>;Defined in: src/api/index.ts:969
Retrieves registered ADAMANT delegates.
Each delegate includes forged, the lifetime sum of block fees and rewards as a base-10 integer string in base units.
Parameters
| Parameter | Type |
|---|---|
options? | GetDelegatesOptions |
Returns
Promise<AdamantApiResult<GetDelegatesResponseDto>>
getDelegatesCount()
getDelegatesCount(): Promise<AdamantApiResult<GetDelegatesCountResponseDto>>;Defined in: src/api/index.ts:1001
Get total count of delegates
Returns
Promise<AdamantApiResult<GetDelegatesCountResponseDto>>
getDelegateStats()
getDelegateStats(generatorPublicKey, options?): Promise<AdamantApiResult<GetDelegateStatsResponseDto>>;Defined in: src/api/index.ts:1009
Gets forging activity for a delegate, optionally within an inclusive Unix timestamp interval.
Parameters
| Parameter | Type |
|---|---|
generatorPublicKey | string |
options? | GetDelegateStatsOptions |
Returns
Promise<AdamantApiResult<GetDelegateStatsResponseDto>>
getEpoch()
getEpoch(): Promise<AdamantApiResult<GetEpochResponseDto>>;Defined in: src/api/index.ts:1105
Returns time when blockchain epoch starts. Value 2017-09-02T17:00:00.000Z is for mainnet.
Returns
Promise<AdamantApiResult<GetEpochResponseDto>>
getFee()
getFee(): Promise<AdamantApiResult<GetTokenTransferFeeResponseDto>>;Defined in: src/api/index.ts:1120
Returns current fee value for type 0 (token transfer) transactions. Integer amount of 1/10^8 ADM tokens (1 ADM = 100000000).
Returns
Promise<AdamantApiResult<GetTokenTransferFeeResponseDto>>
getFees()
getFees(): Promise<AdamantApiResult<GetTransactionTypesFeesResponseDto>>;Defined in: src/api/index.ts:1127
Returns current fee values for different transaction types
Returns
Promise<AdamantApiResult<GetTransactionTypesFeesResponseDto>>
getHeight()
getHeight(): Promise<AdamantApiResult<GetHeightResponseDto>>;Defined in: src/api/index.ts:1112
Returns current node's blockchain height
Returns
Promise<AdamantApiResult<GetHeightResponseDto>>
getKVS()
getKVS(options?): Promise<AdamantApiResult<GetKVSResponseDto>>;Defined in: src/api/index.ts:1179
Fetches ADAMANT KVS transactions.
Parameters
| Parameter | Type |
|---|---|
options? | TransactionQuery<KVSOptions> |
Returns
Promise<AdamantApiResult<GetKVSResponseDto>>
getLoadingStatus()
getLoadingStatus(): Promise<AdamantApiResult<GetLoadingStatusResponseDto>>;Defined in: src/api/index.ts:1070
Gets loading status
Returns
Promise<AdamantApiResult<GetLoadingStatusResponseDto>>
getMilestone()
getMilestone(): Promise<AdamantApiResult<GetMilestoneResponseDto>>;Defined in: src/api/index.ts:1141
Return current slot height, which determines reward a delegate will get for forging a block.
Returns
Promise<AdamantApiResult<GetMilestoneResponseDto>>
getNethash()
getNethash(): Promise<AdamantApiResult<GetNethashResponseDto>>;Defined in: src/api/index.ts:1134
The nethash describes e.g. the Mainnet or the Testnet, that the node is connecting to.
Returns
Promise<AdamantApiResult<GetNethashResponseDto>>
getNextForgers()
getNextForgers(limit?): Promise<AdamantApiResult<GetNextForgersResponseDto>>;Defined in: src/api/index.ts:1029
Returns a next-block snapshot of upcoming forger public keys.
The node builds the entire result from the delegate schedule for currentBlock + 1, including at round boundaries. Request a new snapshot after another block is accepted.
Parameters
| Parameter | Type | Description |
|---|---|---|
limit? | number | Number of public keys to retrieve, from 1 to 101. Defaults to 10. |
Returns
Promise<AdamantApiResult<GetNextForgersResponseDto>>
getNodeStatus()
getNodeStatus(): Promise<AdamantApiResult<GetNodeStatusResponseDto>>;Defined in: src/api/index.ts:1174
Returns ADAMANT blockchain network and Node information in a single request, including the effective consensus activation heights and complete block reward milestone schedule.
Returns
Promise<AdamantApiResult<GetNodeStatusResponseDto>>
getNodeVersion()
getNodeVersion(): Promise<AdamantApiResult<GetNodeVersionResponseDto>>;Defined in: src/api/index.ts:1091
Gets node's software information
Returns
Promise<AdamantApiResult<GetNodeVersionResponseDto>>
getPeer()
getPeer(ip, port): Promise<AdamantApiResult<GetPeerInfoResponseDto>>;Defined in: src/api/index.ts:1063
Finds a peer known to the active node.
Parameters
| Parameter | Type |
|---|---|
ip | string |
port | number |
Returns
Promise<AdamantApiResult<GetPeerInfoResponseDto>>
getPeers()
getPeers(options?): Promise<AdamantApiResult<GetPeersResponseDto>>;Defined in: src/api/index.ts:1058
Gets list of connected peer nodes
Parameters
| Parameter | Type |
|---|---|
options? | GetPeersOptions |
Returns
Promise<AdamantApiResult<GetPeersResponseDto>>
getPingStatus()
getPingStatus(): Promise<AdamantApiResult<GetPingStatusResponseDto>>;Defined in: src/api/index.ts:1084
Checks if the connected node is alive
Returns
Promise<AdamantApiResult<GetPingStatusResponseDto>>
getPublicKey()
getPublicKey(address): Promise<string>;Defined in: src/api/index.ts:553
Get account Public Key
Parameters
| Parameter | Type |
|---|---|
address | `U${string}` |
Returns
Promise<string>
getQueuedTransaction()
getQueuedTransaction(id): Promise<AdamantApiResult<GetQueuedTransactionsResponseDto>>;Defined in: src/api/index.ts:1239
Get queued transaction by ID
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Promise<AdamantApiResult<GetQueuedTransactionsResponseDto>>
getQueuedTransactions()
getQueuedTransactions(options?): Promise<AdamantApiResult<GetQueuedTransactionsResponseDto>>;Defined in: src/api/index.ts:1229
Get queued transactions count
Parameters
| Parameter | Type |
|---|---|
options? | PooledTransactionsOptions |
Returns
Promise<AdamantApiResult<GetQueuedTransactionsResponseDto>>
getReward()
getReward(): Promise<AdamantApiResult<GetRewardResponseDto>>;Defined in: src/api/index.ts:1149
Returns reward — the reward a delegate will get for forging a block. Integer amount of 1/10^8 ADM tokens (1 ADM = 100000000). Depends on the slot height.
Returns
Promise<AdamantApiResult<GetRewardResponseDto>>
getStatus()
getStatus(): Promise<AdamantApiResult<GetNetworkInfoResponseDto>>;Defined in: src/api/index.ts:1165
Returns blockchain network information in a single request, including the latest cumulative consensusCodeName active at the current height.
Returns
Promise<AdamantApiResult<GetNetworkInfoResponseDto>>
getSupply()
getSupply(): Promise<AdamantApiResult<GetTokensTotalSupplyResponseDto>>;Defined in: src/api/index.ts:1157
Returns total current supply of ADM tokens in network. Integer amount of 1/10^8 ADM tokens (1 ADM = 100000000). Total supply increases with every new forged block.
Returns
Promise<AdamantApiResult<GetTokensTotalSupplyResponseDto>>
getSyncStatus()
getSyncStatus(): Promise<AdamantApiResult<GetSyncStatusResponseDto>>;Defined in: src/api/index.ts:1077
Gets information on node's sync process with other peers
Returns
Promise<AdamantApiResult<GetSyncStatusResponseDto>>
getTopAccounts()
getTopAccounts(options?): Promise<AdamantApiResult<GetTopAccountsResponseDto>>;Defined in: src/api/index.ts:904
Gets non-zero-balance accounts ordered by balance descending.
ADAMANT Node v0.10.2 and newer return pagination metadata and support an optional delegate-status filter.
Parameters
| Parameter | Type |
|---|---|
options? | GetTopAccountsOptions |
Returns
Promise<AdamantApiResult<GetTopAccountsResponseDto>>
getTransaction()
getTransaction(id, options?): Promise<AdamantApiResult<GetTransactionByIdResponseDto>>;Defined in: src/api/index.ts:1209
Get transaction by ID
Parameters
| Parameter | Type |
|---|---|
id | string |
options? | TransactionQuery<TransactionsOptions> |
Returns
Promise<AdamantApiResult<GetTransactionByIdResponseDto>>
getTransactions()
getTransactions(options?): Promise<AdamantApiResult<GetTransactionsResponseDto>>;Defined in: src/api/index.ts:1194
Returns list of transactions
Parameters
| Parameter | Type |
|---|---|
options? | TransactionQuery<TransactionsOptions> |
Returns
Promise<AdamantApiResult<GetTransactionsResponseDto>>
getTransactionsCount()
getTransactionsCount(): Promise<AdamantApiResult<GetTransactionsCountResponseDto>>;Defined in: src/api/index.ts:1222
Get confirmed, unconfirmed and queued transactions count
Returns
Promise<AdamantApiResult<GetTransactionsCountResponseDto>>
getUnconfirmedTransaction()
getUnconfirmedTransaction(id): Promise<AdamantApiResult<GetUnconfirmedTransactionByIdResponseDto>>;Defined in: src/api/index.ts:1259
Get unconfirmed transaction by ID
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Promise<AdamantApiResult<GetUnconfirmedTransactionByIdResponseDto>>
getUnconfirmedTransactions()
getUnconfirmedTransactions(options?): Promise<AdamantApiResult<GetUnconfirmedTransactionsResponseDto>>;Defined in: src/api/index.ts:1249
Get unconfirmed transactions
Parameters
| Parameter | Type |
|---|---|
options? | PooledTransactionsOptions |
Returns
Promise<AdamantApiResult<GetUnconfirmedTransactionsResponseDto>>
getVoteData()
getVoteData(address): Promise<AdamantApiResult<GetAccountVotesResponseDto>>;Defined in: src/api/index.ts:1049
Gets current votes of specific ADAMANT account
Parameters
| Parameter | Type | Description |
|---|---|---|
address | string | address of the account to get votes |
Returns
Promise<AdamantApiResult<GetAccountVotesResponseDto>>
getVoters()
getVoters(publicKey): Promise<AdamantApiResult<GetVotersResponseDto>>;Defined in: src/api/index.ts:1040
Gets list of delegate's voters
Parameters
| Parameter | Type | Description |
|---|---|---|
publicKey | string | representing delegate's publicKey |
Returns
Promise<AdamantApiResult<GetVotersResponseDto>>
initSocket()
initSocket(options): void;Defined in: src/helpers/healthCheck.ts:100
Parameters
| Parameter | Type |
|---|---|
options | | WsOptions | WebSocketClient |
Returns
void
Inherited from
NodeManager.initSocketnewDelegate()
newDelegate(passphrase, username): Promise<
| {
errorMessage: string;
success: boolean;
}
| Omit<unknown, "success"> & {
success: true;
}>;Defined in: src/api/index.ts:593
Register new delegate within given username
Parameters
| Parameter | Type | Description |
|---|---|---|
passphrase | string | - |
username | string | The new delegate's username |
Returns
Promise< | { errorMessage: string; success: boolean; } | Omit<unknown, "success"> & { success: true; }>
onReady()
onReady(callback): void;Defined in: src/helpers/healthCheck.ts:91
Parameters
| Parameter | Type |
|---|---|
callback | () => void |
Returns
void
Inherited from
NodeManager.onReadypost()
post<T>(endpoint, options): Promise<AdamantApiResult<T>>;Defined in: src/api/index.ts:546
Makes POST request to ADAMANT network.
endpoint should be in 'accounts/getPublicKey' format, excluding '/api/'.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
endpoint | string |
options | unknown |
Returns
Promise<AdamantApiResult<T>>
searchDelegates()
searchDelegates(q, options?): Promise<AdamantApiResult<SearchDelegateResponseDto>>;Defined in: src/api/index.ts:991
Searches delegates by partial or full username.
Search results include voter and registration details, but unlike the delegate list and single-delegate endpoints they do not include forged.
Parameters
| Parameter | Type | Description |
|---|---|---|
q | string | A username fragment from 1 to 20 characters. |
options? | SearchDelegatesOptions | - |
Returns
Promise<AdamantApiResult<SearchDelegateResponseDto>>
sendMessage()
sendMessage(
passphrase,
addressOrPublicKey,
message,
type?,
amount?,
isAmountInADM?): Promise<
| {
errorMessage: string;
success: boolean;
}
| Omit<unknown, "success"> & {
success: true;
}>;Defined in: src/api/index.ts:617
Encrypt a message, creates Message transaction, signs it, and broadcasts to ADAMANT network.
Parameters
| Parameter | Type | Default value |
|---|---|---|
passphrase | string | undefined |
addressOrPublicKey | string | undefined |
message | string | undefined |
type | MessageType | MessageType.Chat |
amount? | number | undefined |
isAmountInADM? | boolean | undefined |
Returns
Promise< | { errorMessage: string; success: boolean; } | Omit<unknown, "success"> & { success: true; }>
sendTokens()
sendTokens(
passphrase,
addressOrPublicKey,
amount,
isAmountInADM?):
| {
errorMessage: string;
success: boolean;
}
| Promise<AdamantApiResult<unknown>>;Defined in: src/api/index.ts:704
Send tokens to an account
Parameters
| Parameter | Type | Default value |
|---|---|---|
passphrase | string | undefined |
addressOrPublicKey | string | undefined |
amount | number | undefined |
isAmountInADM | boolean | true |
Returns
| { errorMessage: string; success: boolean; } | Promise<AdamantApiResult<unknown>>
sendTransaction()
sendTransaction(request): Promise<AdamantApiResult<RegisterTransactionResponseDto>>;Defined in: src/api/index.ts:1202
Broadcasts an already-created and signed transaction.
Parameters
| Parameter | Type |
|---|---|
request | RegisterTransactionRequestBody |
Returns
Promise<AdamantApiResult<RegisterTransactionResponseDto>>
setKVS()
setKVS(request): Promise<AdamantApiResult<SetKVSResponseDto>>;Defined in: src/api/index.ts:1187
Broadcasts an already-created and signed KVS transaction.
Parameters
| Parameter | Type |
|---|---|
request | SetKVSRequestBody |
Returns
Promise<AdamantApiResult<SetKVSResponseDto>>
updateNodes()
updateNodes(isPlannedUpdate?): Promise<void>;Defined in: src/helpers/healthCheck.ts:125
Parameters
| Parameter | Type | Default value |
|---|---|---|
isPlannedUpdate | boolean | false |
Returns
Promise<void>
Inherited from
NodeManager.updateNodesvoteForDelegate()
voteForDelegate(passphrase, votes): Promise<
| {
errorMessage: string;
success: boolean;
}
| Omit<unknown, "success"> & {
success: true;
}>;Defined in: src/api/index.ts:774
Vote for specific delegates
Parameters
| Parameter | Type | Description |
|---|---|---|
passphrase | string | Account's passphrase |
votes | string[] | Array with public keys. For upvote, add leading + to delegate's public key. For downvote, add leading - to delegate's public key. |
Returns
Promise< | { errorMessage: string; success: boolean; } | Omit<unknown, "success"> & { success: true; }>
Example
voteForDelegate(
'apple banana cherry date elderberry fig grape hazelnut iris juniper kiwi lemon',
[
'+b3d0c0b99f64d0960324089eb678e90d8bcbb3dd8c73ee748e026f8b9a5b5468',
'-9ef1f6212ae871716cfa2d04e3dc5339e8fe75f89818be21ee1d75004983e2a8',
'+system',
'-U16615166477939602094'
]
)