Relay
SupportGet in TouchTry Relay
Relay PlatformAPI ReferenceRelayKitRelay ProtocolChangelog

Getting Started

What is Relay?How Relay Works

Solutions

Payment Service ProvidersWallets & Wallet ProvidersMultichain AppsChainsCommerce & Payments

Use Cases

Bridging & OnboardingSwapsCall Execution

Features

App FeesFee SponsorshipDeposit AddressesGas Top-UpGasless ExecutionFast FillGasless SwapsPrice StabilizationRouting Integration Models

Security

Transaction ScreeningUnsupported ExchangesBug Bounty ProgramMEV protectionCommunity SupportContract Audits

Resources

Supported ChainsIntegrating using AISupportBrand Assets

API Reference

API OverviewQuickstartApps, API keys, and Rate LimitsAccess TokensUnderstanding Step ExecutionWallet DetectionCost & Fee StructureRefundsInput ValidationTrade TypesSurplus & ShortageHandling Quote ErrorsHandling Rate LimitsHandling Execution ErrorsContract CompatibilityBridging Integration GuideCall Execution Integration GuideTransaction IndexingBase Builder CodesSmart Accounts in RelayTestnet SupportSolana SupportBitcoin SupportHyperliquid SupportLighter SupportDeep LinkingWebsocketsWebhooksMigrating to Requests v3Migrating to Currencies v2Migrating to Token Price v2Supported ChainsContract AddressesSupported Tokens & RoutesTroubleshootingGet QuoteSubmit PermitGet StatusGet RequestsGet Published RequestsGet ChainsGet Chains LiquidityGet CurrenciesGet Currency ClassificationsGet Token PriceTransactions IndexTransactions SingleDeposit Address ReindexGet App Fee BalancesGet Balance EventsClaim App FeesGet UsageFast FillGet Swap SourcesCreate Access TokenExecute Gasless TxsAttest DepositGet Recovery BalancesRequest WithdrawalGet Withdrawal StatusGet Requests (v2)Get PriceGet ConfigGet Execution StatusGet Currencies (v1)Get Token Price (v1)Get Quote

RelayKit

OverviewInstallationcreateClientgetQuoteexecutegetAppFeesclaimAppFeesfastFillexecuteGaslessBatchAdaptersTypescript API TypingsChain UtilsInstallationuseQuoteuseRelayChainsuseRequestsuseTokenListuseTokenPriceuseExecutionStatusInstallationRelayKitProviderSwapWidgetThemingTroubleshooting

Protocol

Relay ProtocolHow It WorksThe Relay ChainDepositoryDeposit AddressesOracleHubAllocatorSecurity CouncilSecurity & AuditsFor AppsProgrammatic WithdrawalsWithdrawing with a SafeOperate a Third-Party Relay OracleAddressesEVM Depository ReferenceSVM Depository ReferenceOverviewArchitectureSecurityRelay Vaults BackendBridgingInteracting with Relay VaultsWithdrawing from Relay VaultsRelayPoolFactoryRelayPoolRelayPoolNativeGatewayRelayBridgeFactoryRelayBridge

Changelog

Changelog
## Documentation Index Fetch the complete documentation index at: https://docs.relay.link/llms.txt Use this file to discover all available pages before exploring further.
## Agent Instructions To quote bridges and swaps, look up chains and tokens, or track Relay transactions from an agent, use the Relay MCP server: npx -y @relayprotocol/relay-mcp. It is read-only and does not sign or broadcast transactions. Setup: https://docs.relay.link/resources/developing-with-ai.md For Relay Protocol's trust model, security architecture, and audits, see https://docs.relay.link/references/protocol/security.md. For address screening, see https://docs.relay.link/security/transaction-screening.md.

Base Builder Codes

Attribute onchain activity by appending builder codes to your Relay transactions

Base builder codes are a way to attribute onchain activity. Each code enhances onchain transactions with offchain metadata and makes your application more discoverable. To learn more about builder codes, see the Base documentation.

How to add a builder code

A builder code is an ERC-8021 dataSuffix appended to the end of a deposit transaction's calldata. The called contract ignores the trailing bytes, but indexers read them to credit your application.

Relay matches an onchain transaction to its quote by requestId. Appending bytes to arbitrary calldata changes the transaction, so the solver can no longer match it and the request stops tracking — even though the transaction succeeds onchain. To avoid this, request an explicit deposit quote: set `explicitDeposit` to true. The explicit flow routes funds through the Relay Depository contract that carries the order ID as an argument, so the solver tracks the deposit by that order ID rather than by exact calldata — trailing suffix bytes don't affect it.

Builder codes only work for quotes that route through the Relay Depository contract; same-chain swaps don't use the deposit flow and can't carry a builder code.

Example

[!WARNING] Starting October 2, 2026, POST /quote/v2 will require a valid API key on every request. Pass your key in the x-api-key header — see API keys and Rate Limits. Requests that include a referrer already require the key today. quote/v2 remains fully supported for authenticated requests.
import {
  createWalletClient,
  custom,
  concatHex,
  toHex,
  stringToHex,
  size,
  type Hex,
} from "viem";
import { base } from "viem/chains";

// ERC-8021 suffix = 1-byte length + builder code (ASCII) + 1-byte version + 16-byte marker.
const ERC8021_MARKER = "0x80218021802180218021802180218021" as const; // 0x8021 repeated 8×
const ERC8021_VERSION = "0x00" as const;

function buildDataSuffix(builderCode: string): Hex {
  const codeHex = stringToHex(builderCode);
  const lenByte = toHex(size(codeHex), { size: 1 });
  return concatHex([lenByte, codeHex, ERC8021_VERSION, ERC8021_MARKER]);
}

async function fetchQuote(req: Record<string, unknown>) {
  const res = await fetch("https://api.relay.link/quote/v2", {
    method: "POST",
    headers: { "content-type": "application/json" },
    body: JSON.stringify(req),
  });
  if (!res.ok) throw new Error(`Relay quote failed: ${res.status} ${await res.text()}`);
  return res.json();
}

// Append the suffix to the deposit step only — that is the depositErc20 call the
// Depository tracks by order ID, so trailing bytes don't break requestId matching.
function applyDataSuffix(quote: any, dataSuffix: Hex) {
  return {
    ...quote,
    steps: quote.steps.map((step: any) =>
      step.id !== "deposit"
        ? step
        : {
            ...step,
            items: step.items.map((item: any) => ({
              ...item,
              data: { ...item.data, data: concatHex([item.data.data, dataSuffix]) },
            })),
          }
    ),
  };
}

const walletClient = createWalletClient({ chain: base, transport: custom(window.ethereum) });
const [account] = await walletClient.getAddresses();

// 1. Request an explicit-deposit quote (required for builder codes).
const quote = await fetchQuote({
  user: account,
  recipient: account,
  originChainId: 8453, // Base
  destinationChainId: 42161, // Arbitrum
  originCurrency: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base
  destinationCurrency: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", // USDC on Arbitrum
  amount: "1000000", // 1 USDC (6 decimals)
  tradeType: "EXACT_INPUT",
  protocolVersion: "v2",
  explicitDeposit: true,
});

// 2. Append your builder code to the deposit calldata.
const dataSuffix = buildDataSuffix("YOUR_BUILDER_CODE");
const quoteWithSuffix = applyDataSuffix(quote, dataSuffix);

// 3. Execute each transaction step in order (approval first, then deposit).
for (const step of quoteWithSuffix.steps) {
  if (step.kind !== "transaction") continue;
  for (const { data: tx } of step.items) {
    await walletClient.sendTransaction({
      account,
      to: tx.to,
      data: tx.data,
      value: BigInt(tx.value ?? 0),
      chainId: tx.chainId,
    });
  }
}

Caveats

  • Builder codes require an explicit deposit: set `explicitDeposit` to true and `protocolVersion` to "v2" in your quote request.
  • Only quotes that route through the Relay Depository contract (depositErc20) support builder codes. Same-chain swaps do not.
  • Append the suffix to the deposit step only.

This documentation is built and hosted on Mintlify, a developer documentation platform.

PreviousTransaction IndexingNextSmart Accounts in Relay
Relay© 2026 Uneven Labs, Inc. All rights reserved.XGitHubSupport