- B20 is an ERC-20 superset, so any app that already accepts ERC-20 accepts B20 with no code changes.
- B20 adds a memo:
transferWithMemoattaches abytes32order ID to a payment and emits aMemoevent right after the standardTransfer. - You’ll tag a payment with an order ID, then reconcile it by reading the
Memoevent through your Chainstack node.
Main article
B20 is Base’s native, ERC-20-compatible token standard. Standardtransfer, transferFrom, approve, balanceOf, and permit all work, so existing ERC-20 payment code accepts B20 unchanged.
What B20 adds for payments is the memo: transferWithMemo works like transfer but also attaches a bytes32 reference — such as an order ID — and emits a Memo event immediately after the standard Transfer. Reading that event ties each on-chain payment to an order in your system, which you do through your Chainstack Base node.
This guide tags a payment with an order ID and reconciles it from events. It uses Base Sepolia; the same flow works on Base mainnet after the June 25, 2026 Beryl activation.
Prerequisites
- A Chainstack account and a Base node — see deploy a node.
- A B20 token to accept — see Base: deploy a B20 token. The payer must hold a balance.
- Base’s Foundry build (
base-cast) for the CLI examples, or viem for the app examples.
Tag a payment with an order ID
transferWithMemo(to, amount, memo) sends the tokens and records the order ID. Encode the order ID as bytes32:
B20 decimals range from 6 to 18 — read
decimals() rather than assuming 18.Reconcile payments through your Chainstack node
On the merchant side, read theMemo event to match each incoming payment to its order. The event is Memo(address indexed caller, bytes32 indexed memo), and it sits immediately after the payment’s Transfer in the same transaction.
For per-payment confirmation, read the order ID from the transaction receipt — it already carries the
Memo log. When scanning for past payments with getLogs, query confirmed blocks rather than the exact chain head: a load-balanced endpoint can briefly serve a node a block behind, so a range at the head can error until the node catches up.transferFromWithMemo — it emits the same Memo event.
Handle B20-specific reverts
A B20 transfer can revert where a plain ERC-20 would not. Surface these so a failed payment is visible, not silent:PolicyForbids— the sender or recipient isn’t authorized by the token’s transfer policy. Most tokens are open by default, but a regulated issuer can gate transfers with an allowlist or blocklist.ContractPaused— the issuer paused the token’sTRANSFERfeature.
viem