Installation
Creating a client
- Pass your API key via the
apiKey
property. - Provide
fetchFn
when running in environments without a globalfetch
implementation.
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
deleteWallet
resolves 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
asset
must align with the wallet network (ETH
,USDC
,USDT
,BTC
,TRX
).- Failed broadcasts return
[false, "<provider message>"]
so you can surface the reason in logs or UI. - Include
metadata
to 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
btcFee
accepts a tier ("low"
,"normal"
,"high"
) or a sat/kByte string when broadcasting BTC transactions.ethFee
lets you override the gas limit (defaults to 21,000 for ETH and 65,000 for ERC-20 transfers).ethMaxPriorityFeePerGas
andethMaxFeePerGas
mirror the EIP-1559 fields in wei; keep the max fee greater than or equal to the priority fee.- Include
metadata
in 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.
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
getTransaction
accepts either the 1151 transaction ID (tx_<uuid>
) or the on-chain transaction hash and returns aTransaction
helper.Transaction
instances expose getters forid
,direction
,asset
,amount
,destination
,success
,metadata
, andrawData
for the full payload.
Transaction
helpers in reverse chronological order so you can display recent activity immediately.
Error handling
- Non-2xx responses throw
HttpError
with the originalResponse
for 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
: