Skip to content
A customer buys a 1 USDC sticker from a demo shop: the customer pays, the shop’s server checks the payment onchain, and only then is the order paid. Press Run to step through this tutorial’s code on a local test network (Surfpool). Nothing is sent from your browser, and no real money moves.
Demo Sticker ShopLocal test network (Surfpool)
Holographic sticker1.00 USDCNot paid yetPayment sent · not verified yetPaid · ready to ship
  1. The customer pays 1 USDC The order asks for 1,000,000 base units (1 USDC) and carries a fresh reference. The customer’s wallet approves one USDC transfer to the shop, and payStore returns the transaction’s signature. The shop hasn’t checked anything yet.
  2. The shop’s server verifies the payment The checkout sends the signature to the shop’s server. The server fetches that transaction from the network and checks that it succeeded, carries the order’s reference, and moved exactly 1 USDC of the USDC mint into the shop’s account. Only then is the order paid.
# Step 1/2 · The customer pays 1 USDC
order
{
id: 'order-1001',
storeOwner: 'DVxMtF9M6EAQ8CjqH9omYUTXdJU7hu4M8G94udRyr1m6',
amount: 1000000n,
reference: '47venn787GZLWUcgUU3QM1CpT11JHQMs8hyYQMPXKN2W'
}
const signature = await payStore(customer, order)
signature
'paxK3zbseZEZpGrmGrzm3p3VYF5XN6aTAGKS1sVt2CmkcJ2afLCTB5C84rFT8VFX6LboNFty2pzcTCiVJw5DAtJ'
Payment sent · not verified yet
# Step 2/2 · The shop’s server verifies the payment
await verifyPayment({ ...order, signature, mint: USDC_MINT })
{ paid: true }
Verified: amount, mint, recipient, and reference
Verified. The shop’s server confirmed that 1 USDC for order-1001 reached the shop, so the order can ship.
That’s the whole customer experience: one approval, and the payment settles in under a second. The same code runs on devnetDevnet & mainnetDevnet is a free public test network that behaves like the real one (mainnet), with play money. Same code, different URL.Learn more (Devnet & mainnet: Devnet is a free public test network that behaves like the real one (mainnet), with play money. Same code, different URL.) and on mainnet; only the URL and the USDC address change.

​What just happened

Step 1 is the customer’s side. The order and the approval became a transaction:
  • amount: 1000000n. USDC has 6 decimals, so 1 USDC is 1,000,000 base units. Code always works in base units.
  • storeOwner. The shop’s wallet. The USDC goes to the shop’s USDC account for that wallet.
  • reference. A fresh address created for this order and attached to the transfer. The shop uses it to tell which order a payment is for.
  • signature. The transaction’s ID, which payStore returns once the network has confirmed the transfer. The checkout hands it to the shop’s server.
The network fee for this transfer was 5,000 lamports (0.000005 SOL), paid by the customer’s wallet. Go live shows how your app can pay it instead. The money has moved, but the order isn’t paid until the shop checks. Step 2 is the shop’s side: its server looks the transaction up by its signature and returns { paid: true } only if it succeeded, carries the order’s reference, and moved exactly 1 USDC of the USDC mint into the shop’s account. The shop goes by the network’s record, not the customer’s word. The 1 USDC did not move between the two wallets directly. It moved from the customer’s USDC account to the shop’s USDC account:

​What a wrong amount looks like

The same check refuses a payment that doesn’t match the order. Here the 1 USDC payment from above is checked against an order that costs 2 USDC:
What a wrong amount looks likeLocal test network (Surfpool)
await verifyPayment({ ...order, amount: 2_000_000n, signature, mint: USDC_MINT })
{
paid: false,
reason: 'amount mismatch: expected 2000000, received 1000000'
}
Refused: amount mismatch
The shop doesn’t ship. Step 3 builds the endpoint that runs this check, and also refuses a signature that was already used for another order.

​See it on mainnet

To watch real USDC transfers settle on mainnet, open USDC in Solana Explorer.