Skip to content

Reference

createBuyTrafficRequest

Purchase sequencer traffic from a validator — SDK fills domain id from Amulet rules and generates tracking metadata.

createBuyTrafficRequest POSTs to /wallet/buy-traffic-requests. The SDK implementation calls getAmuletRules first to discover domain_id, derives receiving_validator_party_id from your argument or defaults to [client.getPartyId()], synthesizes a tracking_id, and builds expires_at relative to the current clock before forwarding JSON matching validator expectations.

Setup

import { Canton } from '@fairmint/canton-node-sdk';

const canton = new Canton({
  network: 'devnet',
  provider: '5n',
  partyId: 'OWN_PARTY_ID',
});

Import and receiver

import { Canton } from '@fairmint/canton-node-sdk';

Receiver: canton.validator.createBuyTrafficRequest.

Minimal example

const req = await canton.validator.createBuyTrafficRequest({
  traffic_amount: 1000,
});

const reqOtherValidator = await canton.validator.createBuyTrafficRequest({
  traffic_amount: 500,
  receiving_validator_party_id: 'validator::party...',
});

Parameters

  • traffic_amount (required, number) — Quantity of traffic units to purchase (positive integer semantics enforced server-side).
  • receiving_validator_party_id (optional, string) — Validator party receiving credits—defaults to the SDK party id when omitted.

Internally the SDK augments the outgoing JSON with domain_id, tracking_id, and expires_at; callers pass only the fields above.

Returns

  • request_contract_id (string) — Ledger contract reference correlating this purchase workflow once persisted—poll getBuyTrafficRequestStatus.

Errors and pitfalls

  • Throws synchronously if the client lacks getAmuletRules — use ValidatorApiClient.
  • Missing domain_id inside Amulet rules payload raises errors—refresh Canton infra health before retry loops.

Auth and party

Bearer token authorized for wallet routes; traffic routing ties to validator tenancy configured on Canton networks.

See also

Source

src/clients/validator-api/operations/v0/wallet/buy-traffic-requests/create.ts on GitHub.