---
title: "8. Submitting Transactions in TypeScript"
url: "https://radix.wiki/developers/transactions/08-typescript-transaction-building"
updated: 2026-11-24
license: CC-BY-4.0
license_url: "https://creativecommons.org/licenses/by/4.0/"
version: "1.0.0"
---

# 8. Submitting Transactions in TypeScript

|  |  |
| --- | --- |
| Series | [Transactions track](/developers/transactions), part 8 |
| Packages | [@radixdlt/babylon-gateway-api-sdk](https://www.npmjs.com/package/@radixdlt/babylon-gateway-api-sdk) 1.10.1 and [@radixdlt/radix-engine-toolkit](https://www.npmjs.com/package/@radixdlt/radix-engine-toolkit) 1.0.6 |
| Builds | V1 `NotarizedTransaction`, submitted with `transactionSubmit` |
| Tested with | Node.js 24, submitted to [Stokenet](/contents/tech/releases/stokenet) on 24 November 2026 |

## 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](https://github.com/radixdlt/typescript-radix-engine-toolkit/blob/main/README.md); [Gateway SDK README](https://github.com/radixdlt/babylon-gateway/blob/main/sdk/typescript/README.md)).

This guide is one program that creates a key and an account on [Stokenet](/contents/tech/releases/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](/developers/transactions/07-rust-transaction-building). Reading balances and other state with the same SDK is covered in [Gateway SDK: Reading Ledger State](/developers/frontend/02-gateway-sdk).

## 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](https://www.npmjs.com/package/@radixdlt/babylon-gateway-api-sdk); [toolkit on npm](https://www.npmjs.com/package/@radixdlt/radix-engine-toolkit)).

```
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](https://nodejs.org/api/typescript.html)).

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](/contents/tech/core-concepts/subintents-and-pre-authorizations) 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](https://github.com/radixdlt/babylon-gateway/blob/main/sdk/typescript/lib/helpers/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](https://github.com/radixdlt/babylon-gateway/blob/main/sdk/typescript/README.md)). 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](https://docs.radixdlt.com/docs/concepts-getting-test-xrd-and-paying-fees-from-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](https://github.com/radixdlt/radixdlt-scrypto/blob/main/radix-engine/assets/blueprints/faucet/src/lib.rs)). 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](https://docs.radixdlt.com/docs/account)). Its second argument, `Enum()`, 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("") "try_deposit_batch_or_abort" Expression("ENTIRE_WORKTOP") Enum();
```

For an exchange-style integration, the toolkit's `SimpleTransactionBuilder.freeXrdFromFaucet` builds the same transaction in one call; [Exchange Integration](/developers/infrastructure/03-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 {
  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  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](https://docs.radixdlt.com/docs/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](/developers/transactions/02-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](https://docs.radixdlt.com/docs/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](https://github.com/radixdlt/typescript-radix-engine-toolkit/blob/main/README.md)).
- **The manifest.** `ManifestBuilder` produces the parsed form the `TransactionBuilder` takes, not manifest text; [Radix Engine Toolkit](/developers/transactions/04-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](https://github.com/radixdlt/babylon-gateway/blob/main/sdk/typescript/lib/generated/apis/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](/developers/transactions/02-transaction-lifecycle)).

On 24 November 2026 the [faucet transaction](https://stokenet-dashboard.radixdlt.com/transaction/txid_tdx_2_1jzfd07xenksvxyvaya5guh80ucx42n48nvmmexav3k2u2uqqx00q0kuth6) moved 10,000 $XRD from the faucet to the new account and the faucet paid its 0.58 $XRD fee. The [transfer](https://stokenet-dashboard.radixdlt.com/transaction/txid_tdx_2_1suty6k6m9m0lpxtn3pvp6h5hsycuj2qsur6r78jevqftvgzyuahs8c4ryz) 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

- [Gateway SDK: Reading Ledger State](/developers/frontend/02-gateway-sdk) – balances, metadata and transaction history with the same client
- [Exchange Integration](/developers/infrastructure/03-exchange-integration) – transfers for many accounts with the toolkit's `SimpleTransactionBuilder`
- [Transaction Fees](/developers/transactions/03-transaction-fees) – what the fee each transaction paid is made of
- [Building Transactions in Rust](/developers/transactions/07-rust-transaction-building) – V2 transactions and subintents

## External Links

- [@radixdlt/babylon-gateway-api-sdk on npm](https://www.npmjs.com/package/@radixdlt/babylon-gateway-api-sdk)
- [@radixdlt/radix-engine-toolkit on npm](https://www.npmjs.com/package/@radixdlt/radix-engine-toolkit)
- [Gateway SDK source](https://github.com/radixdlt/babylon-gateway/tree/main/sdk/typescript) – babylon-gateway repository
- [TypeScript Radix Engine Toolkit source](https://github.com/radixdlt/typescript-radix-engine-toolkit)
- [The faucet](https://docs.radixdlt.com/docs/concepts-getting-test-xrd-and-paying-fees-from-the-faucet) – Radix documentation
- [Gateway API reference](https://docs.radixdlt.com/api-reference/gateway-api-specs)
