---
title: "Exact"
description: "Fixed-price x402 payments where the buyer authorizes exactly the advertised amount."
---
The `exact` scheme is a fixed-price payment scheme. The seller advertises one amount, the buyer signs for that exact amount, and the facilitator settles that payment for the request.
Use `exact` when the final charge is known before the response is generated, such as a fixed-price API call, file download, or gated page.
### Server Setup
```typescript
import { HTTPFacilitatorClient } from "@x402/core/server";
import { paymentMiddleware, x402ResourceServer } from "@x402/express";
import { ExactEvmScheme } from "@x402/evm/exact/server";
import { ExactSvmScheme } from "@x402/svm/exact/server";
const facilitatorClient = new HTTPFacilitatorClient({
url: "https://x402.org/facilitator",
});
const resourceServer = new x402ResourceServer(facilitatorClient)
.register("eip155:84532", new ExactEvmScheme())
.register("solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1", new ExactSvmScheme());
app.use(
paymentMiddleware(
{
"GET /weather": {
accepts: [
{
scheme: "exact",
price: "$0.001",
network: "eip155:84532",
payTo: "0xYourAddress",
},
{
scheme: "exact",
price: "$0.001",
network: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
payTo: "YourSolanaAddress",
},
],
description: "Weather data",
mimeType: "application/json",
},
},
resourceServer,
),
);
```
```go
routes := x402http.RoutesConfig{
"GET /weather": {
Accepts: x402http.PaymentOptions{
{
Scheme: "exact",
Price: "$0.001",
Network: "eip155:84532",
PayTo: "0xYourAddress",
},
{
Scheme: "exact",
Price: "$0.001",
Network: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
PayTo: "YourSolanaAddress",
},
},
Description: "Weather data",
MimeType: "application/json",
},
}
handler := nethttpmw.X402Payment(nethttpmw.Config{
Routes: routes,
Facilitator: facilitatorClient,
Schemes: []nethttpmw.SchemeConfig{
{Network: x402.Network("eip155:84532"), Server: exactevm.NewExactEvmScheme()},
{Network: x402.Network("solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"), Server: exactsvm.NewExactSvmScheme()},
},
})(mux)
```
```python
from fastapi import FastAPI
from x402.http import FacilitatorConfig, HTTPFacilitatorClient, PaymentOption
from x402.http.middleware.fastapi import PaymentMiddlewareASGI
from x402.http.types import RouteConfig
from x402.mechanisms.evm.exact import ExactEvmServerScheme
from x402.mechanisms.svm.exact import ExactSvmServerScheme
from x402.server import x402ResourceServer
app = FastAPI()
facilitator = HTTPFacilitatorClient(FacilitatorConfig(url="https://x402.org/facilitator"))
server = x402ResourceServer(facilitator)
server.register("eip155:84532", ExactEvmServerScheme())
server.register("solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1", ExactSvmServerScheme())
routes = {
"GET /weather": RouteConfig(
accepts=[
PaymentOption(
scheme="exact",
price="$0.001",
network="eip155:84532",
pay_to="0xYourAddress",
),
PaymentOption(
scheme="exact",
price="$0.001",
network="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
pay_to="YourSolanaAddress",
),
],
description="Weather data",
mime_type="application/json",
),
}
app.add_middleware(PaymentMiddlewareASGI, routes=routes, server=server)
```
### Upfront payment flow
By default, `exact` uses the `authorization` flow: the payment is verified before the resource handler runs and settled after. When your resource needs on-chain finality before execution — for example, a long-running handler on Solana where the signed transaction's blockhash may expire before the handler finishes — you can opt in to the `upfront` flow instead.
With `upfront`, settlement happens **before** the handler runs. The facilitator's `/settle` endpoint both validates and commits the payment; `/verify` is not called. The client signs the same payload as in `authorization`; only the server-side ordering changes.
To opt in, set `paymentFlow: "upfront"` in the route's `extra` config:
```typescript
app.use(
paymentMiddleware(
{
"GET /weather": {
accepts: [
{
scheme: "exact",
price: "$0.001",
network: "eip155:84532",
payTo: evmAddress,
extra: { paymentFlow: "upfront" },
},
{
scheme: "exact",
price: "$0.001",
network: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
payTo: svmAddress,
extra: { paymentFlow: "upfront" },
},
],
},
},
resourceServer,
),
);
```
```go
routes := x402http.RoutesConfig{
"GET /weather": {
Accepts: x402http.PaymentOptions{
{
Scheme: "exact",
Price: "$0.001",
Network: x402.Network("eip155:84532"),
PayTo: evmAddress,
Extra: map[string]interface{}{
"paymentFlow": "upfront",
},
},
{
Scheme: "exact",
Price: "$0.001",
Network: x402.Network("solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"),
PayTo: svmAddress,
Extra: map[string]interface{}{
"paymentFlow": "upfront",
},
},
},
},
}
```
```python
routes = {
"GET /weather": RouteConfig(
accepts=[
PaymentOption(
scheme="exact",
price="$0.001",
network="eip155:84532",
pay_to=evm_address,
extra={"paymentFlow": "upfront"},
),
PaymentOption(
scheme="exact",
price="$0.001",
network="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
pay_to=svm_address,
extra={"paymentFlow": "upfront"},
),
],
),
}
```
The `authorization` flow remains the default. Clients prefer `authorization` when both flows are offered; the server signals the resolved flow to clients via `extra.paymentFlow` in the 402 response. See [Payment flows](/schemes/overview#payment-flows) for a comparison of all flows.
### Client Setup
```typescript
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { ExactSvmScheme } from "@x402/svm/exact/client";
import { createKeyPairSignerFromBytes } from "@solana/kit";
import { base58 } from "@scure/base";
import { privateKeyToAccount } from "viem/accounts";
const evmSigner = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`);
const svmSigner = await createKeyPairSignerFromBytes(
base58.decode(process.env.SVM_PRIVATE_KEY!),
);
const client = new x402Client();
client.register("eip155:*", new ExactEvmScheme(evmSigner));
client.register("solana:*", new ExactSvmScheme(svmSigner));
```
```go
import (
x402 "github.com/x402-foundation/x402/go/v2"
exactevm "github.com/x402-foundation/x402/go/v2/mechanisms/evm/exact/client"
exactsvm "github.com/x402-foundation/x402/go/v2/mechanisms/svm/exact/client"
evmsigners "github.com/x402-foundation/x402/go/v2/signers/evm"
svmsigners "github.com/x402-foundation/x402/go/v2/signers/svm"
)
evmSigner, err := evmsigners.NewClientSignerFromPrivateKey(os.Getenv("EVM_PRIVATE_KEY"))
if err != nil {
log.Fatal(err)
}
svmSigner, err := svmsigners.NewClientSignerFromPrivateKey(os.Getenv("SVM_PRIVATE_KEY"))
if err != nil {
log.Fatal(err)
}
x402Client := x402.Newx402Client().
Register("eip155:*", exactevm.NewExactEvmScheme(evmSigner, nil)).
Register("solana:*", exactsvm.NewExactSvmScheme(svmSigner))
```
```python
import os
from eth_account import Account
from x402 import x402Client
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact.register import register_exact_evm_client
from x402.mechanisms.svm import KeypairSigner
from x402.mechanisms.svm.exact.register import register_exact_svm_client
client = x402Client()
account = Account.from_key(os.getenv("EVM_PRIVATE_KEY"))
register_exact_evm_client(client, EthAccountSigner(account))
svm_signer = KeypairSigner.from_base58(os.getenv("SVM_PRIVATE_KEY"))
register_exact_svm_client(client, svm_signer)
```
### Casper Setup
The Casper implementation uses CEP-3009 (`transfer_with_authorization`) — Casper's adaptation of EIP-3009 for CEP-18 tokens. The client signs an off-chain EIP-712 authorization; the facilitator relays it on-chain and pays the gas.
**Server**
Install the Casper package:
```bash
npm install @x402/casper
```
```typescript
import { x402ResourceServer } from "@x402/core/server";
import { ExactCasperScheme } from "@x402/casper/exact/server";
const resourceServer = new x402ResourceServer(facilitatorClient)
.register("casper:casper-test", new ExactCasperScheme());
// In your route config — price must be specified as an explicit asset amount:
{
"GET /data": {
accepts: [
{
scheme: "exact",
price: {
amount: "1500000000", // atomic units
asset: "0cb6f94834c60510d532b0ae077b18b4100874a4c867396d61c2b13c790ead52", // contract_package_hash
extra: { name: "csprUSD", version: "1" },
},
network: "casper:casper-test",
payTo: "007a9f9948cb7b258d18f3c5e85780372971b5b40096e724c9e596c284a01445fa",
},
],
description: "Data endpoint",
mimeType: "application/json",
},
}
```
```go
import (
x402 "github.com/x402-foundation/x402/go/v2"
x402http "github.com/x402-foundation/x402/go/v2/http"
nethttpmw "github.com/x402-foundation/x402/go/v2/http/nethttp"
casperserver "github.com/x402-foundation/x402/go/v2/mechanisms/casper/exact/server"
)
facilitatorClient := x402http.NewHTTPFacilitatorClient(&x402http.FacilitatorConfig{
URL: "https://x402.org/facilitator",
})
// Price must be specified as an explicit asset amount for Casper
routes := x402http.RoutesConfig{
"GET /data": {
Accepts: x402http.PaymentOptions{
{
Scheme: "exact",
Price: "$0.001",
Network: x402.Network("casper:casper-test"),
PayTo: "007a9f9948cb7b258d18f3c5e85780372971b5b40096e724c9e596c284a01445fa",
},
},
Description: "Data endpoint",
MimeType: "application/json",
},
}
handler := nethttpmw.X402Payment(nethttpmw.Config{
Routes: routes,
Facilitator: facilitatorClient,
Schemes: []nethttpmw.SchemeConfig{
{
Network: x402.Network("casper:casper-test"),
Server: casperserver.NewExactCasperScheme(),
},
},
})(mux)
```
**Client**
```typescript
import { createClientCasperSigner } from "@x402/casper";
import { ExactCasperScheme } from "@x402/casper/exact/client";
import { x402Client } from "@x402/core/client";
// Default algorithm is ED25519; pass 2 for secp256k1
const casperSigner = await createClientCasperSigner(process.env.CASPER_PRIVATE_KEY!);
const client = new x402Client()
.register("casper:*", new ExactCasperScheme(casperSigner));
```
```go
import (
x402 "github.com/x402-foundation/x402/go/v2"
exactcasper "github.com/x402-foundation/x402/go/v2/mechanisms/casper/exact/client"
caspersigners "github.com/x402-foundation/x402/go/v2/signers/casper"
)
// Load signer from hex-encoded private key; algo is "ed25519" or "secp256k1"
casperSigner, err := caspersigners.NewClientSignerFromSecret(
os.Getenv("CASPER_PRIVATE_KEY"), "ed25519",
)
if err != nil {
log.Fatal(err)
}
x402Client := x402.Newx402Client().
Register("casper:*", exactcasper.NewExactCasperScheme(casperSigner))
```
**Facilitator**
```typescript
import { createFacilitatorCasperSigner } from "@x402/casper";
import { ExactCasperScheme } from "@x402/casper/exact/facilitator";
import { x402Facilitator } from "@x402/core/facilitator";
const casperSigner = await createFacilitatorCasperSigner(
process.env.CASPER_PRIVATE_KEY!,
1, // 1 = ED25519, 2 = secp256k1
{
rpcUrlConfig: { "casper:casper-test": process.env.CASPER_RPC_URL! },
// Optional: enable speculative execution for preflight validation
// speculativeRpcUrlConfig: { "casper:casper-test": process.env.CASPER_SPECULATIVE_RPC_URL! },
},
);
const facilitator = new x402Facilitator()
.register("casper:casper-test", new ExactCasperScheme(casperSigner));
```
```go
import (
"github.com/make-software/casper-go-sdk/v2/types/keypair"
x402 "github.com/x402-foundation/x402/go/v2"
casperfacilitator "github.com/x402-foundation/x402/go/v2/mechanisms/casper/exact/facilitator"
caspersigners "github.com/x402-foundation/x402/go/v2/signers/casper"
)
privKey, err := caspersigners.NewPrivateKeyFromSecret(
os.Getenv("CASPER_PRIVATE_KEY"), "ed25519",
)
if err != nil {
log.Fatal(err)
}
casperSigner := caspersigners.NewFacilitatorSigner(
caspersigners.FacilitatorSignerConfig{
Keys: map[string]keypair.PrivateKey{"casper:casper-test": *privKey},
RpcURLs: map[string]string{"casper:casper-test": os.Getenv("CASPER_RPC_URL")},
// Optional: enable speculative execution for preflight validation
// SpeculativeRpcURLs: map[string]string{"casper:casper-test": os.Getenv("CASPER_SPECULATIVE_RPC_URL")},
},
)
facilitator := x402.Newx402Facilitator()
facilitator.Register(
[]x402.Network{"casper:casper-test"},
casperfacilitator.NewExactCasperScheme(casperSigner, &casperfacilitator.ExactCasperSchemeConfig{}),
)
```
The `asset` field is the 32-byte hex `contract_package_hash` of the CEP-18 token. The `extra.name` and `extra.version` fields are required — they are used to construct the CEP-3009 EIP-712 domain separator.
### XRPL Setup
The XRPL implementation uses payer-signed `Payment` transactions. The payer pays the XRPL transaction fee; facilitator-sponsored fees are not supported.
Install the XRPL package:
```bash
npm install @x402/xrpl
```
**Server**
```typescript
import { x402ResourceServer } from "@x402/core/server";
import { ExactXrplScheme } from "@x402/xrpl/exact/server";
const resourceServer = new x402ResourceServer(facilitatorClient)
.register("xrpl:*", new ExactXrplScheme());
// In your route config:
{
"GET /data": {
accepts: [
{
scheme: "exact",
price: {
amount: "1000000", // 1 XRP in drops
asset: "XRP",
},
network: "xrpl:1", // XRPL testnet
payTo: "rYourXrplAddress",
},
],
description: "Data endpoint",
mimeType: "application/json",
},
}
```
**Client**
```typescript
import { Wallet } from "xrpl";
import { x402Client } from "@x402/core/client";
import { createXrplWalletSigner } from "@x402/xrpl";
import { ExactXrplScheme } from "@x402/xrpl/exact/client";
const wallet = Wallet.fromSeed(process.env.XRPL_SEED!);
const signer = createXrplWalletSigner(wallet);
const client = new x402Client()
.register("xrpl:*", new ExactXrplScheme(signer));
```
**Facilitator**
```typescript
import { x402Facilitator } from "@x402/core/facilitator";
import { ExactXrplScheme } from "@x402/xrpl/exact/facilitator";
const facilitator = new x402Facilitator()
.register("xrpl:*", new ExactXrplScheme());
```
XRPL supports two asset transfer methods via `extra.assetTransferMethod`:
| Method | Description |
|--------|-------------|
| `sequence` | Uses the payer account's current sequence number. Default. One pending payment per account at a time. |
| `ticketSequence` | Uses a pre-created XRPL Ticket. Allows multiple concurrent pending payments per account. |
For `ticketSequence` payments, the client automatically creates a ticket when none is available. To provision tickets explicitly:
```typescript
import { createTickets, createXrplWalletSigner } from "@x402/xrpl";
const ticketSequences = await createTickets(signer, "xrpl:1", 5);
```
### Canton Setup
The Canton implementation uses CIP-56 `TransferFactory_Transfer` — the client signs a prepared transfer instruction naming the merchant as receiver but does not submit it. The signed transaction travels inline (gzip-compressed) in the payment payload, so any facilitator can relay it. The facilitator submits the payer-signed transaction and pays the Canton network traffic fee.
Before receiving payments, the merchant must hold a live `TransferPreapproval` for the payment instrument. Use the `ensureTransferPreapproval` helper to create or renew it:
```bash
npm install @x402/canton
```
**Merchant preapproval (one-time setup)**
```typescript
import { ensureTransferPreapproval } from "@x402/canton";
const result = await ensureTransferPreapproval(
{
participantUrl: process.env.CANTON_PARTICIPANT_URL!,
token: process.env.CANTON_TOKEN!,
userId: process.env.CANTON_USER_ID!,
synchronizerId: process.env.CANTON_SYNCHRONIZER_ID!,
scanUrl: process.env.CANTON_SCAN_URL!,
party: process.env.CANTON_ADDRESS!,
privateKeyPem: process.env.CANTON_PRIVATE_KEY!,
},
{ expiresAt: new Date(Date.now() + 90 * 24 * 60 * 60 * 1000) },
);
console.log(`TransferPreapproval ${result.action}, expires ${result.expiresAt}`);
```
**Server**
```typescript
import { x402ResourceServer } from "@x402/core/server";
import { ExactCantonScheme } from "@x402/canton/exact/server";
const resourceServer = new x402ResourceServer(facilitatorClient)
.register("canton:mainnet", new ExactCantonScheme());
// Canton prices are explicit asset amounts; dollar-string pricing is not supported.
// The instrument admin (DSO for Canton Coin) travels in extra.instrumentId.
{
"GET /data": {
accepts: [
{
scheme: "exact",
price: {
amount: "100000000", // 0.01 CC (1 CC = 1e10 atomic units)
asset: "CC",
extra: {
instrumentId: {
admin: process.env.CANTON_INSTRUMENT_ADMIN!, // DSO party for Canton Coin
id: "Amulet",
},
},
},
network: "canton:mainnet",
payTo: process.env.CANTON_ADDRESS!, // merchant party id
},
],
description: "Data endpoint",
mimeType: "application/json",
},
}
```
**Client**
```typescript
import { x402Client } from "@x402/core/client";
import { toClientCantonSigner } from "@x402/canton";
import { ExactCantonScheme } from "@x402/canton/exact/client";
const cantonSigner = toClientCantonSigner({
participantUrl: process.env.CANTON_PARTICIPANT_URL!,
token: process.env.CANTON_TOKEN!,
userId: process.env.CANTON_USER_ID!,
synchronizerId: process.env.CANTON_SYNCHRONIZER_ID!,
scanUrl: process.env.CANTON_SCAN_URL!,
party: process.env.CANTON_PARTY!,
privateKeyPem: process.env.CANTON_PRIVATE_KEY!,
});
const client = new x402Client()
.register("canton:*", new ExactCantonScheme(cantonSigner));
```
**Facilitator**
```typescript
import { x402Facilitator } from "@x402/core/facilitator";
import { toFacilitatorCantonSigner } from "@x402/canton";
import { ExactCantonScheme } from "@x402/canton/exact/facilitator";
const cantonSigner = toFacilitatorCantonSigner({
participantUrl: process.env.CANTON_PARTICIPANT_URL!,
token: process.env.CANTON_TOKEN!,
userId: process.env.CANTON_USER_ID!,
synchronizerId: process.env.CANTON_SYNCHRONIZER_ID!,
facilitatorParties: [process.env.CANTON_FACILITATOR_PARTY!],
});
const facilitator = new x402Facilitator()
.register(
"canton:mainnet",
new ExactCantonScheme(cantonSigner, {
synchronizerId: process.env.CANTON_SYNCHRONIZER_ID!,
networks: ["canton:mainnet"],
}),
);
```
Canton Coin (`CC`) is the native unit (1 CC = 1e10 atomic units). Dollar-string pricing (`"$0.01"`) is not supported for Canton — always specify an explicit `amount` and `asset`. The `extra.instrumentId` field identifies the payment instrument: for Canton Coin, `{ admin: "", id: "Amulet" }`.
### Hedera Setup
The Hedera implementation supports two asset transfer methods:
| Method | Description |
|--------|-------------|
| `cryptoTransfer` | The payer signs a `TransferTransaction`; the facilitator pays the fee and submits it. Default. |
| `transferExecutor` | An admitted executor contract moves funds a contract controls (smart accounts, vaults, multisigs, or HIP-336 allowances). The client provides an opaque `authorization`; the facilitator builds and submits a `ContractExecuteTransaction`. |
Install the Hedera package:
```bash
npm install @x402/hedera
```
**Server**
```typescript
import { x402ResourceServer } from "@x402/core/server";
import { ExactHederaScheme } from "@x402/hedera/exact/server";
const resourceServer = new x402ResourceServer(facilitatorClient);
resourceServer.register(
"hedera:testnet",
new ExactHederaScheme({
defaultAssets: {
"hedera:testnet": { asset: "0.0.429274", decimals: 6 }, // testnet USDC
},
}),
);
// cryptoTransfer route (default)
const routes = {
"GET /data": {
accepts: [
{
scheme: "exact",
price: { amount: "10000", asset: "0.0.429274" },
network: "hedera:testnet",
payTo: "0.0.7001",
},
],
},
};
// transferExecutor route — quote each method in its own accepts[] entry
const routesWithExecutor = {
"GET /premium": {
accepts: [
{
scheme: "exact",
price: { amount: "10000", asset: "0.0.429274" },
network: "hedera:testnet",
payTo: "0.0.7001",
extra: {
assetTransferMethod: "transferExecutor",
executors: ["0.0.7000"], // narrows the facilitator's admitted list
},
},
// list cryptoTransfer entry first so clients without the hook fall back to it
{
scheme: "exact",
price: { amount: "10000", asset: "0.0.429274" },
network: "hedera:testnet",
payTo: "0.0.7001",
},
],
},
};
```
**Client**
```typescript
import { x402Client } from "@x402/core/client";
import { createClientHederaSigner, PrivateKey } from "@x402/hedera";
import { ExactHederaScheme } from "@x402/hedera/exact/client";
import type { ClientHederaSigner } from "@x402/hedera";
// Standard cryptoTransfer signer
const signer = createClientHederaSigner(
process.env.HEDERA_ACCOUNT_ID!,
PrivateKey.fromStringECDSA(process.env.HEDERA_PRIVATE_KEY!),
{ network: "hedera:testnet" },
);
const client = new x402Client().register("hedera:*", new ExactHederaScheme(signer));
// transferExecutor signer — implement createTransferExecutorAuthorization
const transferExecutorSigner: ClientHederaSigner = {
accountId: "0.0.4242", // the account the executor debits (vault or smart account)
createPartiallySignedTransferTransaction: async () => {
throw new Error("this payer pays with transferExecutor only");
},
createTransferExecutorAuthorization: async (requirements) => ({
executor: "0.0.7000", // one of requirements.extra.executors
authorization: await myExecutor.authorize(requirements), // 0x-hex
}),
};
```
**Facilitator**
```typescript
import { x402Facilitator } from "@x402/core/facilitator";
import {
AccountId,
Client,
PrivateKey,
createHederaGetTokenCustomFees,
createHederaGetTransactionRecord,
createHederaPreflightTransfer,
createHederaResolveEvmAddress,
createHederaSignAndSubmitTransaction,
createHederaSimulateContractCall,
createHederaSubmitContractExecute,
createHederaVerifyPayerSignature,
type FacilitatorHederaSigner,
} from "@x402/hedera";
import { ExactHederaScheme } from "@x402/hedera/exact/facilitator";
const feePayer = "0.0.5001";
const feePayerKey = PrivateKey.fromStringECDSA(process.env.HEDERA_FACILITATOR_PRIVATE_KEY!);
const buildClient = (network: string) =>
(network === "hedera:mainnet" ? Client.forMainnet() : Client.forTestnet()).setOperator(
AccountId.fromString(feePayer),
feePayerKey,
);
// Base signer (cryptoTransfer)
const facilitatorSigner: FacilitatorHederaSigner = {
getAddresses: () => [feePayer],
signAndSubmitTransaction: createHederaSignAndSubmitTransaction(buildClient, feePayerKey),
verifyPayerSignature: createHederaVerifyPayerSignature(),
preflightTransfer: createHederaPreflightTransfer(),
};
// Add transferExecutor capabilities
const transferExecutorSigner: FacilitatorHederaSigner = {
...facilitatorSigner,
resolveEvmAddress: createHederaResolveEvmAddress(),
getTokenCustomFees: createHederaGetTokenCustomFees(),
simulateContractCall: createHederaSimulateContractCall(),
submitContractExecute: createHederaSubmitContractExecute(buildClient, feePayerKey),
getTransactionRecord: createHederaGetTransactionRecord(),
};
// Register concrete networks (not "hedera:*") so each network's executor list is advertised
const facilitator = new x402Facilitator().register(
["hedera:testnet", "hedera:mainnet"],
new ExactHederaScheme(transferExecutorSigner, {
transferExecutor: {
executors: { "hedera:testnet": ["0.0.7000"] },
gasLimit: 400_000,
},
}),
);
```
`transferExecutor` is enabled on a network only when `transferExecutor` options are set, the network's executor list is non-empty, and the signer has all five capabilities (`resolveEvmAddress`, `getTokenCustomFees`, `simulateContractCall`, `submitContractExecute`, `getTransactionRecord`). When enabled, the facilitator's `/supported` kind advertises `assetTransferMethods: ["cryptoTransfer", "transferExecutor"]` and the admitted `executors` list.
| `transferExecutor` option | Meaning |
|---------------------------|---------|
| `executors` | Admitted executor contract ids (`0.0.x`) per CAIP-2 network. A `"*"` entry admits any contract (not recommended). |
| `gasLimit` | Required. Integer from 1 to 15,000,000. Used for both simulation and submission. |
| `simulationGasCeiling` | Optional. When set, rejects payments whose simulated gas exceeds this ceiling (`simulation_gas_exceeded`). Recommended in production. |
For full protocol details, see the [`exact` Hedera spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_hedera.md).
### Cardano Setup
The Cardano implementation uses a client-signed, facilitator-submitted model: the client builds and signs the complete transaction but never broadcasts it. The facilitator verifies and submits it after the resource handler runs.
**Server**
Install the Cardano package:
```bash
npm install @x402/cardano
```
```typescript
import { x402ResourceServer } from "@x402/core/server";
import { ExactCardanoScheme } from "@x402/cardano/exact/server";
const resourceServer = new x402ResourceServer(facilitatorClient)
.register("cardano:*", new ExactCardanoScheme());
// Address-to-address payment
{
"GET /data": {
accepts: [
{
scheme: "exact",
price: {
amount: "1000000", // 1 USDM (6 decimals)
asset: "c48cbb3d5e57ed56e276bc45f99ab39abe94e6cd7ac39fb402da47ad.0014df105553444d",
},
network: "cardano:mainnet",
payTo: "addr1YourCardanoAddress",
maxTimeoutSeconds: 600,
},
],
},
}
```
Install the Cardano extras:
```bash
pip install 'x402[cardano]'
```
```python
from x402 import x402ResourceServerSync
from x402.http import FacilitatorConfig, HTTPFacilitatorClientSync
from x402.mechanisms.cardano.exact import ExactCardanoServerScheme
facilitator = HTTPFacilitatorClientSync(FacilitatorConfig(url="https://x402.org/facilitator"))
server = x402ResourceServerSync(facilitator)
server.register("cardano:*", ExactCardanoServerScheme())
server.initialize()
```
Use `cardano:mainnet`, `cardano:preprod`, or `cardano:preview`. Dollar prices resolve to USDM on mainnet and preprod; preview requires an explicit asset. An explicit ADA price is `{"asset": "lovelace", "amount": "5000000"}`. Native tokens use `<56-char policy hex>.` with atomic integer amounts.
**Client**
```typescript
import { x402Client } from "@x402/core/client";
import { ExactCardanoScheme } from "@x402/cardano/exact/client";
import { toClientCardanoSigner } from "@x402/cardano";
const provider = {
blockfrost: {
baseUrl: process.env.BLOCKFROST_PREPROD_URL!,
projectId: process.env.BLOCKFROST_PROJECT_ID!,
},
};
const clientSigner = toClientCardanoSigner({
mnemonic: process.env.CARDANO_MNEMONIC!,
network: "cardano:preprod",
provider,
});
const client = new x402Client();
client.register("cardano:*", new ExactCardanoScheme(clientSigner));
```
```python
import os
from x402 import x402ClientSync
from x402.mechanisms.cardano import (
BlockfrostConfig,
CardanoProviderConfig,
ClientCardanoSignerConfig,
to_client_cardano_signer,
)
from x402.mechanisms.cardano.exact import ExactCardanoClientScheme
provider = CardanoProviderConfig(
blockfrost=BlockfrostConfig(
"https://cardano-preprod.blockfrost.io/api/v0",
os.environ["BLOCKFROST_PROJECT_ID"],
)
)
signer = to_client_cardano_signer(
ClientCardanoSignerConfig(
mnemonic=os.environ["CARDANO_MNEMONIC"],
network="cardano:preprod",
provider=provider,
)
)
client = x402ClientSync().register("cardano:*", ExactCardanoClientScheme(signer))
```
Pass this client to the existing `requests`, `httpx`, or MCP adapter. Close the signer when the application shuts down.
**Facilitator**
```typescript
import { x402Facilitator } from "@x402/core/facilitator";
import { ExactCardanoScheme } from "@x402/cardano/exact/facilitator";
import { toFacilitatorCardanoSigner } from "@x402/cardano";
const facilitatorSigner = toFacilitatorCardanoSigner({
network: "cardano:preprod",
provider,
});
const facilitator = new x402Facilitator()
.register("cardano:preprod", new ExactCardanoScheme(facilitatorSigner));
```
```python
from x402 import x402FacilitatorSync
from x402.mechanisms.cardano import (
FacilitatorCardanoSignerConfig,
to_facilitator_cardano_signer,
)
from x402.mechanisms.cardano.exact import ExactCardanoFacilitatorScheme
relay = to_facilitator_cardano_signer(
FacilitatorCardanoSignerConfig(
network="cardano:preprod", provider=provider, await_confirmation=False
)
)
facilitator = x402FacilitatorSync().register(
["cardano:preprod"], ExactCardanoFacilitatorScheme(relay)
)
```
A facilitator needs no mnemonic or funds. Blockfrost supplies transaction inclusion and confirmation depth; Koios is also supported via `KoiosConfig`. Verification, submission, and confirmation polling are synchronous — in an async HTTP application, offload with `asyncio.to_thread`.
The facilitator only broadcasts the client's signed transaction — it requires no funded wallet.
#### Cardano asset transfer methods
The Cardano implementation supports three asset transfer methods via `extra.assetTransferMethod`:
| Method | Description |
|--------|-------------|
| `default` | Address-to-address payment. Standard x402 flow. |
| `masumi` | Locks funds into the Masumi `vested_pay` escrow for agent-to-agent payments with refund and dispute mechanics. |
| `script` | Locks funds into any server-defined contract with an optional arbitrary datum. |
For testnet funds, get test ADA from the [Cardano testnets faucet](https://docs.cardano.org/cardano-testnets/tools/faucet/) and preprod tUSDM from the [tUSDM faucet](https://tusdm.moneta.global).
### Network Implementations
The `exact` scheme has network specifications for EVM, SVM, AVM, Stellar, Aptos, Casper, Hedera, TON, Canton, Cardano, Keeta, Sui, Concordium, NEAR, XRPL, and Bitcoin Lightning (`lnbtc`).
### SVM Multi-Payee Splits
The `exact` scheme on Solana supports distributing a single payment across the merchant and up to eight additional recipients in one atomic transaction. This is useful for platform fees, revenue sharing, referral commissions, or fee-payer cost recovery.
Splits are declared by the server in `extra.splits` and must be within the limits the facilitator advertises. The facilitator pays transaction fees and, optionally, ATA creation rent for marked recipients.
**Server: declaring splits**
Add `splits` to the route's `extra` config. Each split is an absolute carve-out from the total `amount`; `payTo` receives the remainder.
```typescript
app.use(
paymentMiddleware(
{
"GET /weather": {
accepts: [
{
scheme: "exact",
price: "$0.001",
network: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
payTo: "YourSolanaAddress",
extra: {
splits: [
{
payTo: "PlatformFeeAddress",
amount: "50000",
memo: "platform fee",
},
],
},
},
],
description: "Weather data",
mimeType: "application/json",
},
},
resourceServer,
),
);
```
```go
routes := x402http.RoutesConfig{
"GET /weather": {
Accepts: x402http.PaymentOptions{
{
Scheme: "exact",
Price: "$0.001",
Network: x402.Network("solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"),
PayTo: "YourSolanaAddress",
Extra: map[string]interface{}{
"splits": []map[string]interface{}{
{
"payTo": "PlatformFeeAddress",
"amount": "50000",
"memo": "platform fee",
},
},
},
},
},
Description: "Weather data",
MimeType: "application/json",
},
}
```
```python
routes = {
"GET /weather": RouteConfig(
accepts=[
PaymentOption(
scheme="exact",
price="$0.001",
network="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
pay_to="YourSolanaAddress",
extra={
"splits": [
{
"payTo": "PlatformFeeAddress",
"amount": "50000",
"memo": "platform fee",
}
]
},
),
],
description="Weather data",
mime_type="application/json",
),
}
```
**Facilitator: advertising split support**
Splits are off by default. Pass `maxSplits` (1–8) to accept them. Optionally set `ataCreationSponsored` to fund ATA creation for recipients whose token account may not exist yet (costs ~0.002 SOL per creation, funded by the facilitator).
```typescript
import { ExactSvmScheme } from "@x402/svm/exact/facilitator";
import { toFacilitatorSvmSigner } from "@x402/svm";
const svmSigner = toFacilitatorSvmSigner(svmAccount);
facilitator.register(
"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
new ExactSvmScheme(svmSigner, undefined, {
maxSplits: 8,
ataCreationSponsored: true, // optional: fund ATA creation for marked recipients
}),
);
```
```go
import (
svmmech "github.com/x402-foundation/x402/go/v2/mechanisms/svm"
svm "github.com/x402-foundation/x402/go/v2/mechanisms/svm/exact/facilitator"
)
settlementCache := svmmech.NewSettlementCache()
facilitator.Register(
[]x402.Network{"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"},
svm.NewExactSvmScheme(svmSigner, &svm.Config{
SettlementCache: settlementCache,
MaxSplits: 8,
AtaCreationSponsored: true, // optional: fund ATA creation for marked recipients
}),
)
```
```python
from x402.mechanisms.svm.exact import ExactSvmFacilitatorScheme
facilitator.register(
["solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"],
ExactSvmFacilitatorScheme(
signer=svm_signer,
max_splits=8,
ata_creation_sponsored=True, # optional: fund ATA creation for marked recipients
),
)
```
When `ataCreationSponsored` is enabled, a recipient can close its ATA, reclaim the rent, and trigger sponsorship again on the next charge. Operators should enforce out-of-band limits per owner and mint before enabling this option.
The facilitator advertises `maxSplits` and `ataCreationSponsored` in its `/supported` response. The server's `enhancePaymentRequirements` throws if a route requests more splits, or ATA sponsorship, than the selected facilitator advertises. Clients accept valid split requirements by default; applications can inspect `selectedRequirements.extra.splits` in `x402Client.onBeforePaymentCreation` to screen recipients before transaction construction.
For full protocol details, see the [`exact` SVM spec §5](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_svm.md#5-multi-payee-splits-optional).
### SVM Smart Wallet Support
By default, the SVM facilitator only accepts transactions from standard (EOA) wallets using static instruction-layout validation. To also accept payments from Solana smart wallets (Squads, Swig, SPL Governance, etc.), enable simulation-based verification when constructing `ExactSvmScheme` on your facilitator:
```typescript
import { ExactSvmScheme } from "@x402/svm/exact/facilitator";
import { toFacilitatorSvmSigner } from "@x402/svm";
const svmSigner = toFacilitatorSvmSigner(svmAccount);
facilitator.register(
"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
new ExactSvmScheme(svmSigner, undefined, {
enableSmartWalletVerification: true,
}),
);
```
```go
import (
svmmech "github.com/x402-foundation/x402/go/v2/mechanisms/svm"
svm "github.com/x402-foundation/x402/go/v2/mechanisms/svm/exact/facilitator"
)
settlementCache := svmmech.NewSettlementCache()
facilitator.Register(
[]x402.Network{"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"},
svm.NewExactSvmScheme(svmSigner, &svm.Config{
SettlementCache: settlementCache,
EnableSmartWalletVerification: true,
}),
)
```
When `EnableSmartWalletVerification` is enabled, transactions that fail static validation (because they contain smart wallet program instructions) are re-verified by simulating the transaction and inspecting CPI inner instructions for a valid `TransferChecked`. Only programs in the built-in allowlist (Squads Multisig v4, Squads Smart Account, Swig, SPL Governance, Metaplex Core, Lighthouse) can reach this path.
**TypeScript**: `toFacilitatorSvmSigner()` is required when enabling smart wallet verification — it provides the `simulateTransactionWithInnerInstructions`, `getConfirmedTransactionInnerInstructions`, `getTokenAccountBalance`, and `fetchAddressLookupTables` methods needed for simulation-based verification.
**Go**: Your signer must implement `SmartWalletRPCCapabilities` (i.e. `SimulateTransactionWithInnerInstructions`, `GetConfirmedTransactionInnerInstructions`, `GetTokenAccountBalance`, and `FetchAddressLookupTables`) — `NewExactSvmScheme` panics at startup if `EnableSmartWalletVerification` is true and the signer does not satisfy this interface.
Additional options:
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `enableSmartWalletVerification` | `boolean` | `false` | Enable simulation-based verification for smart wallet transactions. |
| `smartWalletMaxComputeUnits` | `number` | `400000` | Maximum compute units allowed for smart wallet transactions. |
| `smartWalletMaxPriorityFeeMicroLamports` | `number` | `50000` | Maximum priority fee in microlamports for smart wallet transactions. |
| `smartWalletAllowedPrograms` | `string[]` | Built-in list | Allowed smart wallet program addresses. Only transactions invoking a program in this list reach simulation-based verification. |
| `preflightInstructionAllowlist` | `InstructionTuple[]` | `[]` | Ordered instruction tuples (program address + discriminator) permitted as a contiguous block immediately before the required protocol instructions on Path 1. A matched block is fee-payer-isolation-checked. Defaults to empty (no preflight instructions accepted). |
| `postflightInstructionAllowlist` | `InstructionTuple[]` | `[]` | Like `preflightInstructionAllowlist`, but immediately after the protocol instructions. Defaults to empty (no postflight instructions accepted). |
| `maxPriorityFeeMicroLamports` | `number` | `5000000` | Maximum compute unit price in microlamports accepted on the static path. The facilitator pays the transaction fee, so this bounds the priority fee a payer can make it pay. |
| `maxComputeUnits` | `number` | `400000` | Maximum compute unit limit accepted on the static path. An SPL transfer with a memo uses ~20k CU; a low ceiling still leaves ample headroom for wallet-injected instructions. |
| `maxRequiredSignatures` | `number` | `2` | Maximum number of required signatures. Every signature adds 5,000 lamports of base fee paid by the facilitator. A typical x402 payment needs two (payer + fee payer). |
| `transactionVersions` | `number[]` | `[0, 1]` | Accepted Solana transaction message versions. Advertised as `extra.transactionVersions` in `/supported`. Pass `[0]` to reject version-1 transactions (e.g. when your RPC does not support them). |
| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `EnableSmartWalletVerification` | `bool` | `false` | Enable simulation-based verification for smart wallet transactions. |
| `SmartWalletMaxComputeUnits` | `*uint32` | `400000` | Maximum compute units allowed for smart wallet transactions. |
| `SmartWalletMaxPriorityFeeMicroLamports` | `*uint64` | `50000` | Maximum priority fee in microlamports for smart wallet transactions. |
| `SmartWalletAllowedPrograms` | `[]string` | Built-in list | Allowed smart wallet program addresses. Only transactions invoking a program in this list reach simulation-based verification. |
| `MaxPriorityFeeMicroLamports` | `*uint64` | `5000000` | Maximum compute unit price in microlamports accepted on the static path. |
| `MaxComputeUnits` | `*uint32` | `400000` | Maximum compute unit limit accepted on the static path. |
| `MaxRequiredSignatures` | `*uint8` | `2` | Maximum number of required signatures. Every signature adds 5,000 lamports of base fee paid by the facilitator. |
| `TransactionVersions` | `[]int` | `[0, 1]` | Accepted Solana transaction message versions. Advertised as `extra.transactionVersions` in `/supported`. Pass `[]int{0}` to reject version-1 transactions. |
| `SettlementCache` | `*SettlementCache` | New cache | Shared settlement cache for duplicate detection. Pass the same instance to V1 and V2 SVM schemes. |
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `preflight_instruction_allowlist` | `list[InstructionTuple]` | `[]` | Ordered instruction tuples (program address + discriminator) permitted as a contiguous block immediately before the required protocol instructions on Path 1. A matched block is fee-payer-isolation-checked. Defaults to empty (no preflight instructions accepted). |
| `postflight_instruction_allowlist` | `list[InstructionTuple]` | `[]` | Like `preflight_instruction_allowlist`, but immediately after the protocol instructions. Defaults to empty (no postflight instructions accepted). |
| `transaction_versions` | `list[int]` | `[0, 1]` | Accepted Solana transaction message versions. Advertised as `extra.transactionVersions` in `/supported`. Pass `[0]` to reject version-1 transactions. |
### EVM Transfer Methods
The EVM implementation supports two transfer methods:
| Method | Description |
|--------|-------------|
| `eip3009` | Uses token-native `transferWithAuthorization`, commonly for USDC. This is the default when supported. |
| `permit2` | Uses Uniswap Permit2 plus the x402 exact proxy, so it can support ERC-20 tokens without EIP-3009. |
Permit2 may require a one-time approval. The gas sponsoring extensions can let the facilitator handle that approval path for compatible tokens.
### Examples
* [TypeScript server example](https://github.com/x402-foundation/x402/tree/main/examples/typescript/servers/express)
* [TypeScript upfront server example](https://github.com/x402-foundation/x402/tree/main/examples/typescript/servers/upfront)
* [TypeScript client example](https://github.com/x402-foundation/x402/tree/main/examples/typescript/clients/fetch)
* [Go server example](https://github.com/x402-foundation/x402/tree/main/examples/go/servers/nethttp)
* [Go upfront server example](https://github.com/x402-foundation/x402/tree/main/examples/go/servers/upfront)
* [Go client example](https://github.com/x402-foundation/x402/tree/main/examples/go/clients/http)
* [Python server example](https://github.com/x402-foundation/x402/tree/main/examples/python/servers/fastapi)
* [Python upfront server example](https://github.com/x402-foundation/x402/tree/main/examples/python/servers/upfront)
* [Python client example](https://github.com/x402-foundation/x402/tree/main/examples/python/clients/requests)
### Specs
* [`exact` spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact.md)
* [`exact` EVM spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_evm.md)
* [`exact` SVM spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_svm.md)
* [`exact` AVM spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_algo.md)
* [`exact` Stellar spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_stellar.md)
* [`exact` Aptos spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_aptos.md)
* [`exact` Hedera spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_hedera.md)
* [`exact` TON spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_ton.md)
* [`exact` Keeta spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_keeta.md)
* [`exact` Concordium spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_concordium.md)
* [`exact` Cardano spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_cardano.md)
* [`exact` Casper spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_casper.md)
* [`exact` Sui spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_sui.md)
* [`exact` NEAR spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_near.md)
* [`exact` XRPL spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_xrpl.md)
* [`exact` Canton spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_canton.md)
* [`exact` Bitcoin Lightning spec](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_lnbtc.md)
### See Also
* [Payment schemes overview](/schemes/overview)
* [Upto](/schemes/upto)
* [Batch settlement](/schemes/batch-settlement)