Installation
Creating a client
- Pass your API key via the
apiKeyproperty. - Provide
fetchFnwhen running in environments without a globalfetchimplementation.
Creating and retrieving wallets
createWallet resolves to a Wallet instance with helper getters, including metadata when you pass a JSON object. getWallet accepts the wallet ID (w_<uuid>), the on-chain address, or the wallet name and returns an empty wallet shell if the resource does not exist.
Deleting wallets
deleteWalletresolves when the API confirms the removal; it throws if the wallet is missing or unauthorized.- Pass either the wallet ID (
w_<uuid>) or the on-chain address to delete the resource.
Sending assets
assetmust align with the wallet network (ETH,USDC,USDT,BTC,TRX) and is optional for ETH when usingethErc20Contract.- Failed broadcasts return
[false, "<provider message>"]so you can surface the reason in logs or UI. - Include
metadatato persist arbitrary JSON with the transaction. client.sendFromWallet({ walletId, ... })accepts a wallet ID or address;wallet.send({ ... })reads the ID from the instance automatically.
wallet.send mirrors the REST API: a boolean indicating success and either the transaction hash or a provider error. Retry logic should branch on the boolean rather than the HTTP status alone.
Customizing fees
btcFeeaccepts a tier ("low","normal","high") or a sat/kByte string when broadcasting BTC transactions.ethFeelets you override the gas limit (defaults to 21,000 for ETH and 65,000 for ERC-20 transfers).ethMaxPriorityFeePerGasandethMaxFeePerGasmirror the EIP-1559 fields in wei; keep the max fee greater than or equal to the priority fee.- Include
metadatain the options object to store additional identifiers alongside the resulting transaction. - All properties are optional—omit them to use the API-estimated values.
wallet.send(...); the helper forwards them to client.sendFromWallet so per-transaction fee control works in either form.
Custom ERC-20 by contract
Send any ERC-20 by specifying its contract. Omitasset and provide ethErc20Contract as a string:
- For Ethereum, provide either
assetorethErc20Contract(not both). amountis in token units for ERC-20 transfers.
BTC multi-output sends
For Bitcoin, you can send to multiple outputs in a single transaction by passing a destinations mapping of{ address: amount } and omitting amount/destination:
- Provide exactly one shape: either
{ amount, destination }or{ destinations }. - Multi-output is currently supported only for BTC.
Accessing UTXOs
txid, vout, amountBtc, confirmations, and the original payload via rawData.
Retrieving transactions
getTransactionaccepts either the 1151 transaction ID (tx_<uuid>) or the on-chain transaction hash and returns aTransactionhelper.Transactioninstances expose getters forid,direction,asset,amount,destination,success,metadata, andrawDatafor the full payload.
Transaction helpers in reverse chronological order so you can display recent activity immediately.
Error handling
- Non-2xx responses throw
HttpErrorwith the originalResponsefor inspection. - Requests automatically abort after the configured timeout and throw a standard
Error. - The SDK adds your API key to the JSON payload automatically; do not duplicate it in the body.
try/catch blocks so you can surface actionable error messages to your operators or user interfaces.
Type support
The package ships with full TypeScript definitions forClient, Wallet, UTXO, and the return payloads. You can import the types from js-1151: