Skip to main content

RPC Micropayments

Updated on
Aug 07, 2026

Overview

The SDK can pay for RPC calls with stablecoins through x402 or MPP. This payment lane does not require a Quicknode account, API key, or provisioned endpoint. Configure a payment wallet and the SDK handles the HTTP 402 Payment Required challenge, signs the payment, and resends the RPC request.

The micropayment APIs are available in SDK 0.8.0 for Rust, Python, and Ruby, and 3.8.0 for Node.js.

Payment pathSDK entry pointBest for
x402 per requestrpc.call or rpc.callWithReceipt with scheme: "x402"One-off EVM or Solana payments
MPP per requestrpc.call or rpc.callWithReceipt with scheme: "mpp"One-off payments on Tempo
x402 credit drawdowngatewayAuthenticate then gatewayDrawdownCallPrepay once and consume credits over many calls
MPP payment channelmppOpen then mppSessionCallDeposit once and authorize calls with off-chain vouchers

The payment network is independent of the blockchain you query. For example, Base Sepolia USDC can pay for an Ethereum Mainnet RPC call.


Use a dedicated payment wallet

Store only the funds needed for RPC payments in this wallet. Do not log the payment configuration because it contains the raw private key. If a request fails with PaymentIndeterminateError, the payment might have settled; check the wallet before retrying.

Install

Install the SDK for your language. Rust payment support is feature-gated; the other language packages include it in their precompiled binaries.


npm install @quicknode/sdk

Pay per request

Set the following payment fields on the RPC configuration:

FieldDescription
schemex402 or mpp
keyRaw private key: EVM/Tempo hex or Solana base58 64-byte secret
payNetworkPayment network as a CAIP-2 identifier, such as eip155:84532
assetToken contract address or Solana mint accepted by the gateway
maxAmountRequired spend ceiling in the asset's integer base units

The examples below configure x402 on Base Sepolia. Change scheme, payNetwork, and asset to an offered MPP payment option to use MPP instead.

import { QuicknodeSdk } from '@quicknode/sdk'

const qn = new QuicknodeSdk({
rpc: {
payment: {
scheme: 'x402',
key: process.env.QN_PAYMENT_KEY!,
payNetwork: 'eip155:84532',
asset: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
maxAmount: '10000',
},
},
})

const blockNumber = await qn.rpc.call('eth_blockNumber', [], 'ethereum-mainnet')

console.log(blockNumber)

Use callWithReceipt in Node.js, or call_with_receipt in the other bindings, when you also need settlement metadata. MPP returns the settlement transaction hash in the receipt; the x402 receipt is null.

maxAmount is a safety ceiling, not the amount to send. It is expressed in integer base units of the selected asset, and the SDK refuses any payment offer above it before signing.

Generate a wallet

The SDK can generate an EVM, Solana, or Tempo wallet offline. It returns the private key once and does not store or recover it.


import { generatePaymentWallet } from '@quicknode/sdk'

const wallet = generatePaymentWallet('evm')
console.log('Fund this address:', wallet.address)
// Persist wallet.key securely now. It cannot be recovered later.

Use evm for x402 EVM payments and MPP on Tempo, or svm for x402 on Solana.

Use x402 credit drawdown

Credit drawdown authenticates the wallet once, purchases prepaid credits, and consumes one credit per successful RPC response. Persist the returned gateway session between processes.

const session = await qn.rpc.gatewayAuthenticate()
const balance = await qn.rpc.gatewayCredits(session)
console.log('Credits:', balance.credits)

const blockNumber = await qn.rpc.gatewayDrawdownCall(
'eth_blockNumber',
session,
'ethereum-mainnet'
)

For Base Sepolia testing, gatewayDrip(session) funds the payment wallet once. It returns the funding transaction hash, not a credit balance. Solana wallets must be funded separately.

Use an MPP payment channel

An MPP channel deposits funds into escrow once, then authorizes calls with cumulative off-chain vouchers. Persist the channel state after every successful operation.

const channel = await qn.rpc.mppOpen('1000000')
const newTotal = (
BigInt(channel.cumulativeSpent) + BigInt(channel.perCall)
).toString()

const blockNumber = await qn.rpc.mppSessionCall(
'eth_blockNumber',
'ethereum-mainnet',
channel,
newTotal
)

// After success, persist the channel with cumulativeSpent set to newTotal.

Use mppTopUp to add funds and mppClose to settle the channel and refund its unused deposit. mppStatus consumes one request unit because the gateway prices every session request; persist its updated cumulative spend too.


Keep payment state durable

The gateway cannot reconstruct a lost local MPP channel record. Advance cumulativeSpent only after a successful call and persist the updated channel immediately.

Next steps


  • Review x402 Payments for supported payment networks, assets, and gateway behavior.
  • Review MPP Payments for charge and session payment details.
Share this doc