RADIX WikiRADIX Wiki

Introduction

A TypeScript program that submits a Radix transaction without a wallet uses two npm packages: the Radix Engine Toolkit, which builds, signs and compiles the transaction on the local machine, and the Gateway API SDK, which sends it to a Gateway and reports what happened to it (toolkit README; Gateway SDK README).

This guide is one program that creates a key and an account on Stokenet, the public test network, fills the account with free test $XRD from the faucet, and then sends 100 $XRD from it, polling each transaction until it commits. It ran while this page was written. It is the TypeScript counterpart of Building Transactions in Rust. Reading balances and other state with the same SDK is covered in Gateway SDK: Reading Ledger State.

Which npm packages do I need?

@radixdlt/babylon-gateway-api-sdk and @radixdlt/radix-engine-toolkit. In November 2026 the newest releases on npm were 1.10.1 of the SDK, published on 6 March 2025, and 1.0.6 of the toolkit, published on 3 December 2025 (SDK on npm; toolkit on npm).

npm install @radixdlt/babylon-gateway-api-sdk@1.10.1 @radixdlt/radix-engine-toolkit@1.0.6

The program below is a TypeScript module that uses top-level await, so the project's package.json needs "type": "module". Node.js 24 runs a .ts file directly by stripping its types, so node submit.ts runs it with no build step (Node.js: TypeScript).

The toolkit's TypeScript package builds V1 transactions only: its 1.0.6 type definitions contain no V2 transaction or subintent builder. A V1 transaction is still accepted by the network; a program that needs subintents builds V2 in Rust instead.

How do I create a GatewayApiClient for Stokenet?

Call GatewayApiClient.initialize with networkId: RadixNetwork.Stokenet and an applicationName. The network ID selects the Gateway URL, https://stokenet.radixdlt.com for Stokenet, and a basePath setting overrides it to point at another Gateway (networks.ts).

const gatewayApi = GatewayApiClient.initialize({
  networkId: RadixNetwork.Stokenet,
  applicationName: "TypeScript submit example",
});

The name is sent as a request header, for statistics. The client has a sub-API for each part of the Gateway API: status, transaction, stream and state. Each one has a few high-level helpers, such as transaction.getStatus, and an innerClient holding every method generated from the Gateway's OpenAPI specification. A generated method takes one object, whose single property is named after the request type (Gateway SDK README). Submission is one of the generated methods, which is why the program reaches it through innerClient.

Is there a Stokenet faucet API?

No: there is no HTTP endpoint to request test $XRD from. The Stokenet faucet is a component on the ledger, called from a transaction manifest like any other component; the Radix docs give three ways to use it: the Radix Wallet's request option for a Stokenet account; a toolkit function that builds the faucet transaction; and a manifest written by hand (Radix docs: the faucet).

The component has two methods. free returns a bucket of 10,000 $XRD, and lock_fee pays the transaction's fee from the faucet's own vault, so an account with no $XRD can receive its first tokens. free records the hash of the transaction that called it and fails if that hash is already recorded, so it pays out once per transaction, and a new transaction can call it again (faucet blueprint source). The docs' example manifest says free gives 1,000 $XRD; the source and the ledger give 10,000.

On Stokenet the faucet's address is component_tdx_2_1cptxxxxxxxxxfaucetxxxxxxxxx000527798379xxxxxxxxxyulkzl. The program reads it from the toolkit with knownAddresses rather than writing it out. The manifest it builds is the docs' manifest, with one change: it deposits with try_deposit_batch_or_abort, which any caller may use and which fails the transaction if the account refuses a deposit, where deposit_batch is callable only by the account's owner (Account). Its second argument, Enum<0u8>(), is None for the optional authorized-depositor badge.

CALL_METHOD Address("component_tdx_2_1cptxxxxxxxxxfaucetxxxxxxxxx000527798379xxxxxxxxxyulkzl") "lock_fee" Decimal("10");
CALL_METHOD Address("component_tdx_2_1cptxxxxxxxxxfaucetxxxxxxxxx000527798379xxxxxxxxxyulkzl") "free";
CALL_METHOD Address("<account>") "try_deposit_batch_or_abort" Expression("ENTIRE_WORKTOP") Enum<0u8>();

For an exchange-style integration, the toolkit's SimpleTransactionBuilder.freeXrdFromFaucet builds the same transaction in one call; Exchange Integration uses it before a transfer with the same builder.

Building, notarizing and compiling the transaction

The whole program, as it ran:

import { GatewayApiClient, RadixNetwork } from "@radixdlt/babylon-gateway-api-sdk";
import {
  Convert, ManifestBuilder, NetworkId, PrivateKey, RadixEngineToolkit, TransactionBuilder,
  address, decimal, enumeration, expression, generateRandomNonce, type TransactionManifest,
} from "@radixdlt/radix-engine-toolkit";
import { randomBytes } from "node:crypto";
 
const gatewayApi = GatewayApiClient.initialize({
  networkId: RadixNetwork.Stokenet,
  applicationName: "TypeScript submit example",
});
 
// A new Ed25519 key and the account address it controls. The address is usable
// at once; the first deposit creates the account on the ledger.
const key = new PrivateKey.Ed25519(new Uint8Array(randomBytes(32)));
const account = await RadixEngineToolkit.Derive.virtualAccountAddressFromPublicKey(key.publicKey(), NetworkId.Stokenet);
const known = await RadixEngineToolkit.Utils.knownAddresses(NetworkId.Stokenet);
const faucet = known.componentAddresses.faucet;
const xrd = known.resourceAddresses.xrd;
console.log("account", account);
 
async function submit(manifest: TransactionManifest): Promise<string> {
  const { ledger_state } = await gatewayApi.status.getCurrent();
  const transaction = await TransactionBuilder.new().then(builder =>
    builder
      .header({
        networkId: NetworkId.Stokenet,
        startEpochInclusive: ledger_state.epoch,
        endEpochExclusive: ledger_state.epoch + 10,
        nonce: generateRandomNonce(),
        notaryPublicKey: key.publicKey(),
        notaryIsSignatory: true,
        tipPercentage: 0,
      })
      .manifest(manifest)
      .notarize(key),
  );
  const intentHash = await RadixEngineToolkit.NotarizedTransaction.intentHash(transaction);
  const compiled = await RadixEngineToolkit.NotarizedTransaction.compile(transaction);
 
  await gatewayApi.transaction.innerClient.transactionSubmit({
    transactionSubmitRequest: { notarized_transaction_hex: Convert.Uint8Array.toHexString(compiled) },
  });
 
  for (let attempt = 0; attempt < 30; attempt++) {
    const status = await gatewayApi.transaction.getStatus(intentHash.id);
    if (status.intent_status === "CommittedSuccess") return intentHash.id;
    if (status.intent_status === "CommittedFailure" || status.intent_status === "PermanentlyRejected")
      throw new Error(`${intentHash.id} ${status.intent_status}: ${status.error_message}`);
    await new Promise(resolve => setTimeout(resolve, 2000));
  }
  throw new Error(`${intentHash.id} still pending after 60 seconds`);
}
 
// 1. The faucet pays the fee and hands out 10,000 test $XRD, deposited to the new account.
const fromFaucet = new ManifestBuilder()
  .callMethod(faucet, "lock_fee", [decimal(10)])
  .callMethod(faucet, "free", [])
  .callMethod(account, "try_deposit_batch_or_abort", [expression("EntireWorktop"), enumeration(0)])
  .build();
console.log("faucet  ", await submit(fromFaucet));
 
// 2. The account pays its own fee and sends 100 $XRD to a second new account.
const recipient = await RadixEngineToolkit.Derive.virtualAccountAddressFromPublicKey(
  new PrivateKey.Ed25519(new Uint8Array(randomBytes(32))).publicKey(), NetworkId.Stokenet);
const transfer = new ManifestBuilder()
  .callMethod(account, "lock_fee", [decimal(1)])
  .callMethod(account, "withdraw", [address(xrd), decimal(100)])
  .callMethod(recipient, "try_deposit_batch_or_abort", [expression("EntireWorktop"), enumeration(0)])
  .build();
console.log("transfer", await submit(transfer));

What each part does:

  • The key and account. PrivateKey.Ed25519 takes 32 random bytes as a plain Uint8Array. Derive.virtualAccountAddressFromPublicKey turns its public key into an account address, which works before anything is deposited; the first deposit creates the account on the ledger and pays the extra cost of doing so (Account).
  • The header. status.getCurrent() reads the current epoch from the Gateway, and the transaction is valid from that epoch for the next 10. The nonce is random, so two otherwise identical transactions have different hashes. The fields are described in Transaction Lifecycle.
  • The notary. notaryIsSignatory: true lets the notary's signature count as a signature on the intent, so one key both signs for the account and notarizes. The transfer needs that signature, because only the account's owner may call lock_fee and withdraw on it (Account). For a key held elsewhere, such as an HSM, notarize and sign take a signing function in place of the key, and notarizeAsync and signAsync take an asynchronous one (toolkit README).
  • The manifest. ManifestBuilder produces the parsed form the TransactionBuilder takes, not manifest text; Radix Engine Toolkit explains the difference. The value helpers decimal, address, expression and enumeration build the typed arguments.
  • Hash and payload. NotarizedTransaction.intentHash returns the transaction ID, the txid_tdx_2_… string the Gateway and the dashboard look transactions up by. NotarizedTransaction.compile returns the payload as bytes, and Convert.Uint8Array.toHexString turns them into the hex string the Gateway takes.

How do I submit it with transactionSubmit?

Pass the hex payload as notarized_transaction_hex, wrapped in a transactionSubmitRequest object, to gatewayApi.transaction.innerClient.transactionSubmit, which posts it to the Gateway's /transaction/submit endpoint (TransactionApi.ts). The response has one field, duplicate, which is true when the Gateway already holds the same transaction as pending.

await gatewayApi.transaction.innerClient.transactionSubmit({
  transactionSubmitRequest: { notarized_transaction_hex: Convert.Uint8Array.toHexString(compiled) },
});

Submission only means the Gateway accepted the payload. The program then calls transaction.getStatus with the transaction ID every two seconds and reads intent_status. It stops on CommittedSuccess, throws on CommittedFailure or PermanentlyRejected, and keeps waiting on anything else, because a pending or possibly rejected transaction can still commit. A committed failure still pays its fee, and neither it nor a permanent rejection can be retried with the same payload: the fix is a new transaction with a new nonce (Transaction Lifecycle).

On 24 November 2026 the faucet transaction moved 10,000 $XRD from the faucet to the new account and the faucet paid its 0.58 $XRD fee. The transfer moved 100 $XRD to the second account and the new account paid its 0.44 $XRD fee. Both committed in epoch 25,384, the transfer about three seconds after the faucet transaction.

Next Steps

HydrateLast updated 5m agov1.0.01 revision
CiteRADIX Wiki. "8. Submitting Transactions in TypeScript." November 24, 2026. https://radix.wiki/developers/transactions/08-typescript-transaction-building