Build Transactions

buildTransaction() returns an unsigned transaction you can preview, evaluate or sign yourself; sendAssets() builds, signs and broadcasts in one call.

buildTransaction() constructs an unsigned transaction without signing or broadcasting it. Use this when you want to inspect or display a transaction before committing, or when you need to implement a custom signing flow.

When to Use

  • Show users a preview of what will happen before they confirm
  • Custom multi-step flows (build → evaluate → sign)
  • Integrating with hardware wallets or external signers

For most cases, sendAssets() (build + sign + broadcast in one call) is simpler.

Build via Client API

import { WalletChain } from "@tatumio/wallet-sdk";

const tx = await client.buildTransaction({
  path: { chain: WalletChain.ETHEREUM_MAINNET },
  body: {
    to: "0xRecipientAddress",
    token: "NATIVE",
    amount: "0.01",
  },
});

Build via Custodian API

Build on behalf of a specific client from the custodian side:

const tx = await wallets.custodian.buildTransaction({
  path: {
    clientId: "{CLIENT_ID}",
    chain: WalletChain.ETHEREUM_MAINNET,
  },
  body: {
    to: "0xRecipientAddress",
    token: "NATIVE",
    amount: "0.01",
  },
});

Response Shapes

The response type depends on the chain. BuildTransactionResponse is a union of the shapes below with no discriminator field, so pass the shape you expect as the type argument, for example client.buildTransaction<Eip155TransactionResult>(...). All fields are optional in the types.

EVM Chains (Eip155TransactionResult)

{
  transaction?: {
    from?: string;   // sender address
    to?: string;     // recipient or contract
    data?: string;   // calldata (empty for native transfers)
    value?: string;  // amount in wei
  };
  metadata?: {
    amount?: string;
    fromAddress?: string;
    toAddress?: string;
    tokenAddress?: string;
    tokenDecimals?: number;
    tokenSymbol?: string;
    rawAmount?: string;
  };
}

Solana (SolanaTransactionResult)

{
  transaction?: string;  // base64-encoded serialized transaction
  metadata?: {
    amount?: string;
    fromAddress?: string;
    toAddress?: string;
    tokenMintAddress?: string;
    tokenDecimals?: number;
    tokenProgramId?: string;
    tokenExtensions?: string[];
    tokenSymbol?: string;
    rawAmount?: string;
    lastValidBlockHeight?: string;
    serializedTransactionBase64Encoded?: string;
    serializedTransactionBase58Encoded?: string;
  };
}

Bitcoin (BitcoinTransactionResult)

{
  transaction?: {
    publicKey?: string;
    rawTxHex?: string;
    signatureHashes?: string[];  // one hash per input to sign
  };
  metadata?: {
    chainId?: string;
    amount?: string;
    fromAddress?: string;
    toAddress?: string;
    rawAmount?: string;
    tokenDecimals?: number;
    tokenSymbol?: string;
    feeInSatoshis?: string;
    changeInSatoshis?: string;
  };
}

Stellar (StellarTransactionResult)

{
  transaction?: {
    xdr?: string;               // XDR-encoded transaction envelope
    networkPassphrase?: string;
  };
  metadata?: {
    amount?: string;
    fromAddress?: string;
    toAddress?: string;
    assetCode?: string;
    assetIssuer?: string | null;
    rawAmount?: string;
  };
}

Tron (TronTransactionResult)

{
  transaction?: {
    id?: string;
    network?: "mainnet" | "nile" | "shasta";
  };
  metadata?: {
    amount?: string;
    fromAddress?: string;
    toAddress?: string;
    tokenSymbol?: string;
    contractAddress?: string | null;
  };
}

Build → Evaluate → Sign Flow

import { WalletChain, type Eip155TransactionResult } from "@tatumio/wallet-sdk";

const chain = WalletChain.ETHEREUM_MAINNET;
const recipient = "0xRecipient";

// 1. Build (narrow the response to the EVM shape)
const tx = await client.buildTransaction<Eip155TransactionResult>({
  path: { chain },
  body: { to: recipient, token: "NATIVE", amount: "0.01" },
});

// 2. Evaluate (optional but recommended)
const evaluation = await client.evaluateTransaction({
  query: { chainId: chain },
  body: {
    to: tx.transaction?.to ?? recipient,
    value: tx.transaction?.value,
    data: tx.transaction?.data,
    operationType: "all",
  },
});

const resultType = evaluation.validation?.resultType;
if (resultType && resultType !== "Benign") {
  throw new Error(`Transaction flagged as ${resultType}`);
}

// 3. Sign and broadcast
const signed = await client.sign({
  body: {
    share: shares.SECP256K1.share,
    method: "eth_sendTransaction",
    params: [tx.transaction],
    chainId: chain,
    to: recipient,
    rpcUrl: `https://ethereum-mainnet.gateway.tatum.io/${process.env.TATUM_API_KEY}`,
  },
});

console.log(signed.data); // transaction hash

Did this page help you?