Skip to content
LogoLogo

Actions

Actions are standalone functions that take a client: action(client, params). Each maps to one REST route; see the REST API reference for response fields.

import { createClient, getBlock, getUtxos } from 'arrekta-sdk'
 
const client = createClient({ url: 'http://127.0.0.1:28332' })
const tip = await getBlock(client, { id: 'tip' })
const coins = await getUtxos(client, { address: 'rarrk1p…' })

Chain and blocks

ActionRoute
getChain(client)GET /v1/chain
getBlock(client, { id })GET /v1/blocks/{id}
getDeployments(client)GET /v1/deployments
getCheckpoints(client)GET /v1/checkpoints
submitCheckpoint(client, { hex })POST /v1/checkpoints

Transactions

ActionRoute
getTransaction(client, { txid })GET /v1/txs/{txid}
getRawTransaction(client, { txid })GET /v1/txs/{txid}/raw
decodeTransaction(client, { hex })POST /v1/txs/decode
sendTransaction(client, { tx | hex })POST /v1/txs
sendPackage(client, { parent, child })POST /v1/txs/package

Addresses and assets

ActionRoute
getAddress(client, { address })GET /v1/addresses/{address}
getUtxos(client, { address, asset? })GET /v1/addresses/{address}/utxos
getAddressHistory(client, { address })GET /v1/addresses/{address}/txs
getAssets(client)GET /v1/assets
getAsset(client, { idOrTicker })GET /v1/assets/{key}
getFrozen(client, { asset })GET /v1/assets/{key}/frozen

Mempool, fees, mining

ActionRoute
getMempool(client)GET /v1/mempool
estimateFee(client)GET /v1/fees
getMiningTemplate(client, { address })GET /v1/mining/template
createAuxBlock(client, { address })POST /rpc createauxblock
submitAuxBlock(client, { hash, auxpow })POST /rpc submitauxblock

Light clients

ActionRoute
getBlockFilter(client, { id })GET /v1/blocks/{id}/filter
getFilterHeaders(client, { start, count })GET /v1/filters/headers

Local verification (verifyFilter, matchFilter, verifyMerkleBranch, verifyCheckpoint) is in the Light client guide.

Events

watchEvents returns an async iterator over the node's SSE stream (/v1/events) or, with a gateway client, /gateway/v1/stream. It reconnects on errors and both streams resume after lastEventId (the node keeps its last 1,000 events and sends stream.reset for older gaps).

import { watchEvents } from 'arrekta-sdk'
 
const controller = new AbortController()
for await (const event of watchEvents(client, { signal: controller.signal })) {
  console.log(event.type, event.id)
}

Full example: Watch events.