Skip to content
LogoLogo

Transactions

Build

import { buildTransaction } from 'arrekta-sdk'
 
const { tx, spent } = buildTransaction({
  coins,                          // mature unspent coins (getCoins)
  payments: [{ address, amount: parseArrk('1.5') }],
  change: keychain.address(0, 1), // change address
  feeRate,                        // base units per 1000 bytes (estimateFee → fee_per_kb)
  network,
  // optional: issuances, mints, freezes, version, validUntil
})

buildTransaction selects coins per asset, adds change, and keeps every non-ARRK asset balanced (inputs + issued + minted = outputs). Set version: 2 and validUntil for an expiring transaction, version: 3 for TRUC.

Sign

import { signTransaction } from 'arrekta-sdk'
 
const signed = signTransaction(tx, spent, keychain.signingKeys(), network)

The signature hash (§6.4) commits to the network, the txid, the input index and the asset, amount and lock of every spent output.

Ids and encoding

FunctionReturns
txid(tx)TH("txid", serialization without witnesses)
wtxid(tx)TH("wtxid", full serialization)
serialize(tx) / deserialize(bytes)the §5 encoding
sighash(tx, i, spentOutputs, network)the message signed for input i

Hashes are lowercase hex in natural byte order (never reversed).

Fee bumping

FunctionDoes
bumpFeerebuilds an unconfirmed transaction at a higher fee rate (full RBF)
cpfpbuilds a child that spends the stuck transaction's change; submit both with sendPackage

Example

/**
 * Send a payment: derive a wallet, fund it on regtest, pay 1.5 ARRK, confirm.
 *
 *   ARREKTA_URL=http://127.0.0.1:28332 ARREKTA_ADMIN_TOKEN=... npx tsx examples/send-payment.ts
 */
import { createClient, formatArrk, fromHex, generateSeed, getAddress, getChain, getCoins, keychainFromSeed, mine, sendPayment } from 'arrekta-sdk';
 
const URL = process.env.ARREKTA_URL ?? 'http://127.0.0.1:28332';
const ADMIN = process.env.ARREKTA_ADMIN_TOKEN; // regtest mining for the demo
const SEED = fromHex(process.env.ARREKTA_SEED ?? 'a1'.repeat(32));
 
// 1. Connect and read the chain.
const client = createClient({ url: URL, adminToken: ADMIN });
const chain = await getChain(client);
console.log(`connected to ${chain.network} at height ${chain.height}`);
 
// 2. Alice's wallet from her seed; Bob gets a fresh one.
const alice = keychainFromSeed(SEED, { network: chain.network });
const bob = keychainFromSeed(generateSeed(), { network: chain.network });
 
// 3. Fund Alice (regtest: mine past coinbase maturity).
if ((await getCoins(client, { wallet: alice })).length === 0) await mine(client, alice.address(0), 101);
 
// 4. Pay Bob 1.5 ARRK (fee rate from the node's estimate).
const sent = await sendPayment(client, { wallet: alice, to: bob.address(0), amount: '1.5' });
console.log(`sent ${sent.txid} (fee ${formatArrk(sent.fee)} ARRK)`);
 
// 5. Confirm and check Bob's balance.
await mine(client, alice.address(0), 1);
const balance = (await getAddress(client, { address: bob.address(0) })).balances[0]!;
console.log(`bob has ${formatArrk(balance.spendable)} ARRK`);

Source: sdk/typescript/examples/send-payment.ts (updated 2026-11-02) · sdk/python/examples/send_payment.py (updated 2026-11-02). Runnable against a regtest node; CI runs every example.