Verify a payment
A purchase from a Chain Daddy store is a payment on a public chain, from the buyer's wallet straight to the seller's. You can prove it happened three ways:
| Way | What it proves | Trusts |
|---|---|---|
| The webhook signature | The event came from Chain Daddy | Us |
| The receipt (a signed JWS) | Chain Daddy confirmed this order for this wallet | Us |
| The chain | The buyer paid exactly this order, to exactly these addresses | Nobody |
A server that hands over something valuable should check the chain before it does.
What you need: the order's verification block
Every order that touches a chain carries it: on GET /api/v2/iap/orders/{id}, in the response that created the order, and on the order of a checkout session you read. A paid order to try it on shows a whole one.
"verification": {
"kind": "evm",
"chainId": "eip155:8453",
"checkout": "0x…",
"feeAddress": "0x…",
"order": {
"orderId": "0x9e1f…",
"token": "0x…",
"payees": ["0x…", "0x…"],
"amounts": ["975000", "25000"],
"deadline": 1791234567
},
"confirmations": 5
}checkoutis the contract the order is paid through.orderis the struct the buyer's wallet signed for: who is paid (payees) and how much each (amounts, in the token's smallest unit).tokenis the zero address for the chain's own coin.confirmationsis how deep we wait before calling the orderconfirmed.- A test order has no
verificationblock.
Before you trust the block, compare it with what you sold: payees[0] is your payout address and amounts[0] your share; feeAddress, when present, is the next payee, and any payee after that is a wallet the item splits its sales with.
With the helper
@chaindaddy/js/verify does the whole check in one call, for an EVM store and for a Solana store (the Solana example). It has no dependencies and runs anywhere fetch does (Node 20 or later).
npm install @chaindaddy/js// verify-order.mjs run: node verify-order.mjs 0x9e1f…
import { verifyPayment, VerifyError } from '@chaindaddy/js/verify';
// What you sold, from YOUR OWN records. Never copy these from the order you are checking.
const SALE = {
chainId: 'eip155:8453', // the chain your store is on
token: process.env.COIN_ADDRESS, // the coin you are paid in (its contract address)
payee: process.env.PAYOUT_ADDRESS, // your payout address
amount: 975000n, // the least it must receive, in the coin's smallest unit
};
const orderId = process.argv[2];
const res = await fetch(`https://api.chaindaddy.io/api/v2/iap/orders/${orderId}`, {
headers: { Authorization: `Bearer ${process.env.CHAINDADDY_IAP_KEY}` },
});
const { verification } = await res.json();
try {
const result = await verifyPayment(verification, {
rpcUrl: process.env.RPC_URL, // your own JSON-RPC endpoint for that chain, not ours
expect: { orderId, ...SALE },
});
console.log(result.paid ? `paid by ${result.payer ?? 'the buyer on the order'}` : 'not paid yet');
} catch (e) {
if (!(e instanceof VerifyError)) throw e;
console.error(`could not verify (${e.code}): ${e.message}`);
}result.paid is true only when the checkout contract itself says this exact order was paid, result.depth blocks deep. false means not yet: ask again later. Anything else throws a VerifyError.
expect is required. A tampered block can describe a real payment of a different order, so the helper refuses any block that is not the order (orderId), the chain (chainId), the asset (token, or NATIVE_TOKEN for the chain's own coin), and at least the amount to your payee that you sold. Take all five from your own records. For amount, start from your price and take off the store fee and any split you set. Pass it as a bigint or a decimal string; a JavaScript number is refused.
An item priced in dollars. Your records hold a dollar price, and the buyer paid in your coin or the chain's coin, at the rate of the moment they pressed Buy. That amount was fixed then, so you cannot work it out beforehand: read it from the order, where payoutAmount is what your payout address receives, in the coin's smallest unit.
const order = await res.json(); // GET /api/v2/iap/orders/{id}, or the session read's `order`
const PRICE_USD_MICROS = 250000; // YOUR price for one, from your own records: $0.25
// The order must have been quoted from your dollar price, in the coin you expect.
if (order.priceUsdMicros !== PRICE_USD_MICROS) throw new Error('not the price I set');
const expect = { orderId, ...SALE, amount: BigInt(order.payoutAmount) };priceUsdMicros is the price of one item, in millionths of a dollar, and usdPerToken is the rate the order used, so amount is about priceUsdMicros × quantity ÷ usdPerToken, rounded up, and payoutAmount is that less the fee and any split. The helper proves the buyer paid what the order locked. For a sale that matters, compare usdPerToken with a price you trust before you deliver. An item priced in dollars and paid in a dollar stablecoin has nothing to convert, so take its amount from your price as above.
An item of an app you installed. Your payout is your share of the price, not the price: the fee and the app developer's share are paid to their own wallets in the same transaction. The helper adds up what the order sends your payee and refuses anything less than expect.amount, so pass what your payout address must receive, which the order reports as payoutAmount. Pass the item's price and you get expectation_mismatch on an order that was paid correctly.
The helper also refuses a checkout that is not one of Chain Daddy's checkout contracts on that chain; the list ships inside the package. If you see unknown_checkout on a fresh order, update @chaindaddy/js.
e.code | Meaning |
|---|---|
expectation_mismatch | The block is not the order, asset, payout address or amount you expect. Do not deliver |
unknown_checkout | The block names a contract that is not a Chain Daddy checkout on that chain |
wrong_chain | The block, your expect.chainId and your RPC endpoint are not all the same chain |
bad_verification | The block is missing or malformed (a test order has none). For a Solana order it also means the block has no order, or its reference and memo are not this order's: read the order again |
bad_options | Something you passed is missing or malformed |
rpc_error | Your RPC endpoint failed, or answered something that is not an answer. Try again |
How deep it reads. The helper reads at the deepest of the package's MIN_CONFIRMATIONS for the chain, the block's confirmations, and yours. Pass confirmations: 30 to wait longer; a smaller number changes nothing.
A Solana store
The call is the same. What you pass in expect is Solana's: the cluster, the mint and your payout wallet.
// verify-solana-order.mjs run: node verify-solana-order.mjs 0x9e1f…
import { verifyPayment, VerifyError } from '@chaindaddy/js/verify';
// What you sold, from YOUR OWN records.
const SALE = {
chainId: 'solana:mainnet', // or 'solana:devnet'
token: process.env.COIN_MINT, // the mint you are paid in; SOLANA_NATIVE_TOKEN for SOL
payee: process.env.PAYOUT_WALLET, // your payout wallet itself, not its token account
amount: 975000n, // the least it must receive, in the coin's smallest unit
};
const orderId = process.argv[2];
const res = await fetch(`https://api.chaindaddy.io/api/v2/iap/orders/${orderId}`, {
headers: { Authorization: `Bearer ${process.env.CHAINDADDY_IAP_KEY}` },
});
const order = await res.json();
try {
const result = await verifyPayment(order.verification, {
rpcUrl: process.env.SOLANA_RPC_URL, // your own RPC endpoint for that cluster, not ours
expect: { orderId, ...SALE },
signature: order.txHash ?? undefined, // the transfer, when you know it
});
if (result.paid) console.log(`paid by ${result.payer} in ${result.signature}`);
else if (result.late) console.log(`paid too late by ${result.payer}: the order did not confirm`);
else console.log('not paid yet');
} catch (e) {
if (!(e instanceof VerifyError)) throw e;
console.error(`could not verify (${e.code}): ${e.message}`);
}A Solana order has no contract to ask, so the helper finds the transfer and checks that the transaction succeeded and is finalized, that its cdiap: memo names this order and the order's reference key rides along, and that every wallet in the block's order.payees received at least its amount of order.token, no later than the order's deadline plus 2 minutes. It works the reference key and the memo out from your expect.orderId, and it refuses an RPC endpoint that is on another cluster.
result | Meaning |
|---|---|
paid: true | A finalized transfer paid this exact order in full and in time. payer, signature, slot and blockTime say which |
late: true | The transfer paid in full but landed more than 2 minutes after the order's deadline. The money reached you and the order did not confirm: settle it with payer |
| neither | Not paid yet, or not finalized yet (a few seconds on a normal day). Ask again later |
- Pass
signaturewhen you have it. It is the order'stxHash. Without it the helper reads at most ten transactions that carry the reference key, oldest first, and a search that is crowded out answers "not paid". A signature of some other transaction changes nothing. - It always reads at
finalized.confirmationsis not used on Solana. - What
expectpins. The order, the cluster, the asset and what your own payout wallet receives. The other payees and the deadline are read from the block.paid: trueproves that you were paid in full; whether the order also confirmed is the order'sstatus. solanaOrderMarkers(orderId)gives the reference key and the memo, if you want to look the transfer up yourself.
Your own client. request takes the place of rpcUrl when you already have one: request: client.request with viem, or any function shaped like ({ method, params }) => result.
A paid order to try it on
A real order paid through a checkout session on Base, as its store's key reads it from GET /api/v2/iap/orders/{id}: a $0.25 item, paid in the store's own coin. Run your check against it before you have a paid order of your own. The receipt and the session id are cut short.
{
"id": "0x38caa142f8f1d23a70a7a7f1cc181cfe03cf9e151aec4b07effea01a959094bd",
"storeId": "f2027681-b969-450a-8794-461730b3b047",
"sku": "nitro.5pack",
"wallet": "0xd5475f6ab7f8c37324ffb6e21da94d3dfdfe00a6",
"quantity": 1,
"appAccountToken": "d8-live-1",
"ref": null,
"chainId": "eip155:8453",
"currency": "0x931fce21ddea0549db70324f44ee2db1cb9f7f22",
"currencyKind": "token",
"currencySymbol": "FLUXGP",
"currencyDecimals": 18,
"amount": "6994000000000000000000",
"payoutAddress": "0x2ca75898788f3aad05e7e4ff247f3db13456b0b4",
"payoutAmount": "6994000000000000000000",
"feeAmount": "0",
"feeBps": 0,
"priceUsdMicros": 250000,
"usdPerToken": "0.00003574575392",
"status": "confirmed",
"expiresAt": "2026-10-11T12:15:02.016368Z",
"txHash": "0xe9a4a0510a8bee90da55eac73a1a9f60b06ef030d734f8db13aeb42a91ca2953",
"payer": "0xd5475f6ab7f8c37324ffb6e21da94d3dfdfe00a6",
"confirmations": 5,
"requiredConfirmations": 5,
"paidAt": "2026-10-11T12:10:14.306506Z",
"confirmedAt": "2026-10-11T12:10:23.020149Z",
"refundedAt": null,
"receipt": "eyJhbGciOiJFZERTQSIs…",
"verification": {
"kind": "evm",
"chainId": "eip155:8453",
"checkout": "0x1825e21c72ebd14a683d56200ee834a371313bf1",
"feeAddress": null,
"order": {
"orderId": "0x38caa142f8f1d23a70a7a7f1cc181cfe03cf9e151aec4b07effea01a959094bd",
"token": "0x931fce21ddea0549db70324f44ee2db1cb9f7f22",
"payees": ["0x2ca75898788f3aad05e7e4ff247f3db13456b0b4"],
"amounts": ["6994000000000000000000"],
"deadline": 1791720902
},
"confirmations": 5
},
"createdAt": "2026-10-11T12:10:02.020408Z",
"checkoutSessionId": "cs_f4e6af46…a081"
}- One payee and no fee. This coin launched in a Chain Daddy launchpad pool, so the store's fee is 0%:
feeAddressisnull, andpayoutAmountequalsamount. A store with a fee has a second payee, as in the first example. - A dollar price.
priceUsdMicrosis $0.25, and 6,994 of the coin is what that came to when the buyer pressed Buy.deadlineis the order'sexpiresAtin unix seconds, 5 minutes after it was made. appAccountTokenis the session'sclientReferenceId, andcheckoutSessionIdthe session the order was made from. An order made any other way has nocheckoutSessionId.- A pending order also carries a
paymentblock (how to pay), and an order with revenue splits asplitslist. Parse both as optional.
Check it with the helper, against any Base endpoint of your own:
// verify-sample.mjs run: RPC_URL=https://… node verify-sample.mjs
import { verifyPayment } from '@chaindaddy/js/verify';
const verification = {
kind: 'evm',
chainId: 'eip155:8453',
checkout: '0x1825e21c72ebd14a683d56200ee834a371313bf1',
feeAddress: null,
order: {
orderId: '0x38caa142f8f1d23a70a7a7f1cc181cfe03cf9e151aec4b07effea01a959094bd',
token: '0x931fce21ddea0549db70324f44ee2db1cb9f7f22',
payees: ['0x2ca75898788f3aad05e7e4ff247f3db13456b0b4'],
amounts: ['6994000000000000000000'],
deadline: 1791720902,
},
confirmations: 5,
};
const result = await verifyPayment(verification, {
rpcUrl: process.env.RPC_URL,
expect: {
orderId: verification.order.orderId,
chainId: 'eip155:8453',
token: '0x931fce21ddea0549db70324f44ee2db1cb9f7f22',
payee: '0x2ca75898788f3aad05e7e4ff247f3db13456b0b4',
amount: 6994000000000000000000n,
},
});
console.log(result.paid, result.payer);
// → true 0xd5475f6ab7f8c37324ffb6e21da94d3dfdfe00a6Raise amount by one, or change payee, and it throws expectation_mismatch instead. In your own code expect comes from your records; here both are written out so the sample runs alone.
EVM: ask the contract
The checkout contract keeps one fact per order: who paid it. Two read-only calls give you the answer.
hashOrder(order)oncheckoutreturns the order's hash, an EIP-712 digest bound to that contract's address and chain. Call thecheckoutthe order names.paidBy(hash)returns the wallet that paid, or the zero address if nobody has.
Ask at a block confirmations deep:
import { createPublicClient, http, zeroAddress } from 'viem';
import { base } from 'viem/chains';
const abi = [
{ type: 'function', name: 'hashOrder', stateMutability: 'view',
inputs: [{ name: 'o', type: 'tuple', components: [
{ name: 'orderId', type: 'bytes32' }, { name: 'token', type: 'address' },
{ name: 'payees', type: 'address[]' }, { name: 'amounts', type: 'uint256[]' },
{ name: 'deadline', type: 'uint256' }] }],
outputs: [{ type: 'bytes32' }] },
{ type: 'function', name: 'paidBy', stateMutability: 'view',
inputs: [{ type: 'bytes32' }], outputs: [{ type: 'address' }] },
];
// `v` is the order's verification block. Use your own RPC, not ours.
async function paidOnChain(v) {
const client = createPublicClient({ chain: base, transport: http(process.env.RPC_URL) });
const order = {
orderId: v.order.orderId, token: v.order.token, payees: v.order.payees,
amounts: v.order.amounts.map(BigInt), deadline: BigInt(v.order.deadline),
};
const head = await client.getBlockNumber();
const blockNumber = head - BigInt(v.confirmations) + 1n; // `confirmations` deep
const hash = await client.readContract({ address: v.checkout, abi, functionName: 'hashOrder', args: [order] });
const payer = await client.readContract({ address: v.checkout, abi, functionName: 'paidBy', args: [hash], blockNumber });
return payer !== zeroAddress ? payer : null;
}A non-zero answer means: this exact order (these payees, these amounts, this token) was paid in full through that contract, by that wallet, at least confirmations blocks ago. The contract moves the tokens from the payer to every payee inside the same call, and reverts unless all of it succeeds, so there is nothing else to check.
When the buyer paid with another coin, the answer is not the buyer. A buyer can pay with a different coin in one transaction through Chain Daddy's swap-pay contract (ChainDaddySwapPay). It swaps their coin and pays the order itself, so paidBy answers the contract's address. The order is still paid in full. The buyer is the order's payer in Chain Daddy's API and store webhook (an empty payer means the buyer is not confirmed yet: do not refund). Never send funds to the swap-pay contract: anything sent there goes to whoever pays through it next. verifyPayment answers payer: null with via: 'swap-pay' for such an order, and SWAP_PAY_HELPERS in @chaindaddy/js/verify lists the contract's addresses.
Or read the payment's log. If you have the transaction hash (txHash on the order), its receipt holds an OrderPaid(bytes32 orderId, address payer, address token, uint256 total, address[] payees, uint256[] amounts) event. Accept it only if the log's address is checkout, orderId is your order's id, and payees and amounts equal the block's. Anyone can emit an event with that name from their own contract, so the address check is the one that matters.
Tokens that take a cut on transfer deliver less than amounts says. The contract records what the order sends, not what arrives.
Solana: find the transfer
A Solana order is paid by an ordinary transfer that carries two markers. The helper does this check for you; these are the same steps by hand:
"verification": {
"kind": "solana",
"cluster": "solana:mainnet",
"reference": "B7t…",
"memo": "cdiap:0x9e1f…",
"order": {
"orderId": "0x9e1f…",
"token": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"payees": ["9xQe…", "Fee1…"],
"amounts": ["4875000", "125000"],
"deadline": 1760400000
}
}cluster is solana:mainnet or solana:devnet: ask an RPC endpoint of that cluster. order is what the transfer has to pay: token is the mint (11111111111111111111111111111111 when the order is paid in SOL), payees are the wallets that are paid (owners, not their token accounts) with the matching amounts, and deadline is in unix seconds. Your payout wallet comes first.
getSignaturesForAddress(reference, { commitment: 'finalized' })lists the transactions that name the order's reference key. There should be one.getTransaction(signature, { commitment: 'finalized' }): check that it succeeded (meta.erris null), that its memo is exactlymemo, and that every wallet inorder.payeesreceived at least its amount: comparemeta.preTokenBalanceswithmeta.postTokenBalancesfor theorder.tokenmint, matching onowner, orpreBalanceswithpostBalanceswhen the order is paid in SOL.- Check the time: the transaction's
blockTimemust be no later thanorder.deadlineplus 120 seconds. A transfer that lands later reached the seller, but the order does not confirm.
The reference key is the order id's 32 bytes read as an address.
Which to use
- Delivering something a buyer could resell or cannot give back: check the chain, then deliver.
- Updating a balance you can correct later: the signed webhook is enough; reconcile from the event feed.
- A buyer says they paid and your server never heard: read the order (
GET /api/v2/iap/orders/{id}), then run the check. If the chain says paid, it is paid.