Transactions
sendTransaction moves value out of a personal, single-signature wallet. Multisig transfers go
through the order lifecycle instead. See Orders.
Prerequisites
Section titled “Prerequisites”Sending reconstructs a private key, so it needs the full session stack:
const userRef = await sdk.getSdkUserId();await sdk.unlockWalletSession(userRef, password);
await sdk.runWithUserRef(userRef, async () => { const { txHash } = await sdk.sendTransaction({ chain: EChainType.EVM, from: senderAddress, to: recipientAddress, amount: '0.1', chainId: 1, tokenAddress: '', decimals: 18, isNativeToken: true, });});runWithUserRef scopes the signing user for the whole callback, keeping concurrent requests
isolated. The alternative is passing userRef on each input.
SendTransactionInput
Section titled “SendTransactionInput”interface SendTransactionInput { /** Opaque user id for session-scoped signing (or use runWithUserRef). */ userRef?: string; chain: EChainType; from: string; to: string; amount: string; symbol?: string; chainId?: number; feeHint?: EstimatedFee; tokenAddress: string; decimals: number; isNativeToken?: boolean; memo?: string; /** Read shares from the personal or the organization partition. */ walletScope?: WalletScope; /** Lets the SDK rebuild a missing or stale device share before signing. */ walletPassword?: string;}
interface SendTransactionOutput { txHash: string;}| Field | Notes |
|---|---|
amount |
Human-readable decimal string ('0.1'), never base units. Each chain converts it with decimals. |
tokenAddress |
Required by the type even for native sends, where you pass ''. For ADA it is the token policy id; for XRP it is "currency.issuer". |
decimals |
Required. Determines the base-unit conversion; Solana defaults to 9 internally if the value is undefined, Tron throws for TRC-20 without it. |
isNativeToken |
Omitted means “not explicitly native”; ADA and XRP treat !== false as native, EVM/Solana/Tron branch on the truthy value. |
chainId |
EVM only. Takes a ChainIdValue string ('11155111') or a plain number. Defaults to 1 when omitted. Other chains derive their chain id from the SDK’s network. |
symbol |
Carried into the spend context as the token symbol. On ADA it doubles as the hex asset name. |
feeHint |
An EstimatedFee from estimateFee, reused instead of re-quoting. |
walletPassword |
Only needed when the device share is missing or stale. It lets the SDK rebuild the share mid-send. |
RPC endpoints
Section titled “RPC endpoints”Sends and fee quotes talk to a chain node. Defaults ship per network, and SDKConfig.rpcOverrides
replaces them:
type RpcOverrides = Partial<Record<ChainIdValue, string>>;const sdk = new TrustodianSDK({ apiKey, network: 'mainnet', shareStore, rpcOverrides: { '1': 'https://my-eth-node.example', 'sol_mainnet': 'https://my-solana-node.example', },});The shipped defaults are public endpoints: fine for trying things out, not for production
throughput. Point rpcOverrides at your own nodes before you go live.
Address validation
Section titled “Address validation”Validate before you send. These helpers check the address’s embedded checksum rather than matching a shape regex, so a single mistyped character is rejected instead of paid to an address nobody controls.
import { validateEvmAddress, validateSolanaAddress, validateTronAddress, validateBitcoinAddress, validateCardanoAddress, validateXrpAddress, validateAddressForChain, assertValidAddressForChain,} from 'vaults-multichain-sdk';| Function | Signature |
|---|---|
validateEvmAddress |
(address: string) => boolean |
validateSolanaAddress |
(address: string) => boolean |
validateTronAddress |
(address: string) => boolean |
validateBitcoinAddress |
(address: string, isMainnet?: boolean) => boolean. Defaults to the SDK’s network |
validateCardanoAddress |
(address: string, isMainnet?: boolean) => boolean. Defaults to the SDK’s network |
validateXrpAddress |
(address: string) => boolean |
validateAddressForChain |
(address, chainType, options?) => AddressValidationResult |
assertValidAddressForChain |
(address, chainType, options?) => void. Throws InvalidInputError |
interface AddressValidationResult { isValid: boolean; error?: string;}
interface AddressValidationOptions { /** Defaults to the SDK's network. Ignored for BTC/BTC_T3, whose chain type already names the network. */ isMainnet?: boolean; field?: string; operation?: string;}const check = validateAddressForChain(recipient, EChainType.XRP);if (!check.isValid) throw new Error(check.error);
// or, to throw directlyassertValidAddressForChain(recipient, EChainType.XRP, { operation: 'send' });Memos and destination tags
Section titled “Memos and destination tags”import { isMemoSupported, validateMemo, getMemoPlaceholder,} from 'vaults-multichain-sdk';Only XRP, Solana and Tron carry a memo. EVM, Bitcoin and Cardano ignore memo entirely.
interface MemoValidationResult { isValid: boolean; error?: string;}
validateMemo(memo: string, chainType: EChainType): MemoValidationResult;getMemoPlaceholder(chainType: EChainType): string;| Chain | Rule | Placeholder |
|---|---|---|
| XRP | Digits only, 0 … 4294967295. Carried as the Payment’s DestinationTag. |
Destination Tag (numeric) |
| Solana | No whitespace, at most 200 characters. Added as an SPL Memo instruction. | Memo (up to 200 characters, no spaces) |
| Tron | No whitespace, at most 200 characters. Attached via addUpdateData as UTF-8. |
Memo (up to 200 characters, no spaces) |
| Everything else | Always valid, and ignored | "" (empty string) |
An empty memo is always valid.
Spend authorization
Section titled “Spend authorization”Before a key is rebuilt, every send hands the unsigned transaction to Trustodian and gets back a single-use handle, which travels with the share request.
This exists because the share request would otherwise carry a recipient and an amount that the client computed, and those are what the Address Book whitelist and the organization spending limit are enforced against. A caller could simply understate them. By reading the payee and amount out of the transaction that is actually about to be signed, the server enforces its policies against the real spend rather than a claim about it.
The SDK does all of this inside sendTransaction; there is no method for you to call and nothing to
configure. What you may see is its effect: a send can be refused by an organization policy at this
step, before any signature exists. Nothing is reserved, so an abandoned send costs no allowance.
Per-chain behaviour
Section titled “Per-chain behaviour”What each chain needs from you, and what it will refuse.
EVM
chainIdselects both the RPC endpoint and the network; it defaults to1.- Token sends need
tokenAddressanddecimals; native sends leavetokenAddressempty and setisNativeToken: true. - A chain id with no configured RPC throws
No RPC endpoint configured for EVM chain ID ….
Solana
- The RPC URL must be
https://. - A native send will not leave the recipient below rent-exemption, and refuses rather than creating an unusable account.
- Sending a token to a recipient who has no account for it creates that account in the same transaction, and the sender pays rent for it. Budget for that.
- Both SPL and Token-2022 tokens are supported; the right one is detected from the mint.
Tron
- Native sends keep about 0.3 TRX back for bandwidth, and refuse when the amount would eat into it: “Insufficient TRX for transaction. Please leave ~0.1 TRX for bandwidth costs.”
- TRC-20 sends require both
tokenAddressanddecimals. - Sending to an account that is not yet activated costs roughly 1 TRX extra.
Bitcoin
- The recipient is checked against the active network before anything else.
- Inputs are selected automatically and the fee comes from the current network rate.
- Change below the dust limit is dropped into the fee rather than creating a dust output.
- Chain type is
BTCon mainnet andBTC_T3on testnet.
Cardano
- For a token transfer,
tokenAddresscarries the policy id andsymbolthe asset name; both are required. amountis the token amount. Every output must also carry a minimum of ADA, which the SDK derives. You do not choose it.- A token send needs pure-ADA UTXOs to pay from. If all the ADA is locked in UTXOs that also hold tokens, the send is refused and the tokens must be moved first.
XRP
- Sending to yourself is refused up front.
- For an issued asset,
tokenAddressmust be"currency.issuer", for example"USD.rIssuer...". A trust line for that pair must already exist; see XRP trust lines. - A numeric
memobecomes the destination tag; a non-numeric one is dropped. - Every account locks 1 XRP as a base reserve plus 0.2 XRP per owned object, and that part of the balance cannot be spent.
Minimum balances and native currencies
Section titled “Minimum balances and native currencies”These are the per-chain floors and native units the SDK works with, reproduced so you can apply the same thresholds yourself.
| Chain | Minimum balance for a transaction | Native asset | Decimals |
|---|---|---|---|
EVM |
0.001 |
ETH | 18 |
SOL |
0.01 |
SOL | 9 |
TRON |
1 |
TRX | 6 |
BTC |
0.0001 |
BTC | 8 |
BTC_T3 |
0.0001 |
BTC | 8 |
ADA |
1 |
ADA | 6 |
XRP |
1 |
XRP | 6 |
Fee estimation
Section titled “Fee estimation”import { TransactionEstimatingType } from 'vaults-multichain-sdk';
const fee = await sdk.estimateFee({ chain: EChainType.EVM, txType: TransactionEstimatingType.Send, payload: { from, to, amount: '0.1' }, chainId: '1',});
fee.estimatedFee; // human units of the native assetfee.currency; // e.g. "ETH"payload.from is the wallet the quote is priced against. For a token transfer add tokenAddress and
decimals. When chainId is omitted it defaults to the SDK’s network: '1' / '11155111' on EVM,
sol_mainnet / sol_devnet, and so on.
Pass the result back as feeHint on sendTransaction to reuse the quote instead of re-pricing it.
New device or missing device share
Section titled “New device or missing device share”If the device share for a wallet is absent or stale, pass walletPassword and the SDK performs a
recovery rotation as part of the send. Without it, the failed send throws an error you can test
with isDeviceShareRecoveryError(error), then retry after recovering explicitly.
await sdk.sendTransaction({ userRef, walletPassword: password, chain: EChainType.EVM, from, to, amount: '0.1', chainId: 1, tokenAddress: '', decimals: 18, isNativeToken: true,});To do the rotation explicitly instead, use
ensureWalletReadyForCrypto or ensureWalletDeviceShare. See
Keeping a device share current for the
recovery pattern and what makes a share stale.
XRP trust lines
Section titled “XRP trust lines”An XRP wallet can only hold an issued asset once a trust line to that currency/issuer pair is open. Opening one consumes 0.2 XRP of the account’s available balance as a reserve object.
interface ActivateXrpTrustLineInput { /** XRP wallet address that will open the trust line */ address: string; /** Currency code, e.g. "USD" or 40-char hex */ currency: string; /** Issuer address, e.g. "rIssuer..." */ issuer: string; /** Max token amount to hold (default: "1000000000") */ limit?: string; walletScope?: WalletScope;}
interface ActivateXrpTrustLineOutput { /** Transaction hash */ hash: string; /** Signed tx blob (hex) */ tx: string; /** Engine result, e.g. "tesSUCCESS" */ result: string;}const { hash, result } = await sdk.activateXrpTrustLine({ address: xrpWallet, currency: 'USD', issuer: 'rIssuerAddress...',});Both address and issuer are validated before any network call. Opening the line needs roughly
0.2 XRP of available balance for the new reserve object.
Inspecting reserve and existing lines
Section titled “Inspecting reserve and existing lines”interface XrpAccountReserveInfo { address: string; totalBalance: string; availableBalance: string; totalReserve: string; baseReserve: string; ownerCount: number; ownerReservePerObject: string; objects: { trustLines: number; signerList: boolean; offers: number; escrows: number; otherObjects: number; };}
interface XrpTrustLineInfo { currency: string; issuer: string; balance: string; limit: string;}const reserve = await sdk.getXrpAccountReserve({ address: xrpWallet });const lines = await sdk.getXrpTrustLines({ address: xrpWallet });Both read straight from the XRP ledger, with no Trustodian API call, and both validate the address first.
Errors worth handling
Section titled “Errors worth handling”| Error | When |
|---|---|
InvalidInputError |
Invalid memo, or a failed assertValidAddressForChain |
InsufficientBalanceError |
Balance is below what the transfer plus fees requires |
OrgPolicyRejectedError |
Refused at spend authorization: whitelist, spending limit, or business hours |
A reconstructed key that fails to derive the wallet’s address does not surface as a thrown
KeyMismatchError instance; catch it with isDeviceShareRecoveryError(error) instead. See
Keeping a device share current.
Use isTrustodianError(error) to narrow before reading these fields. For the full error taxonomy,
HTTP status mapping and retry guidance, see Errors.