ERC-8439 A settlement-decoupled nanopayment ledger (Settlement-Decoupled Nanopayment Ledger)
Draft · Signatures & auth · created 2026-10-09
Having the payment network, the wallet institution, and the acquirer institution all co-sign to record micropayments and refunds on an onchain ledger, so that off-chain systems can process actual fund movement based on it.
Why it is needed
Fiat micropayments (nanopayments) need to handle amounts smaller than the smallest unit of currency in metered services or agent-to-agent interactions. Processing this with existing approaches requires the wallet institution and acquirer institution to establish direct account relationships with each other, preventing the payment network from decoupling the debt obligations. Furthermore, without a shared ledger where the three parties, the payment network, wallet institution, and acquirer institution, can jointly verify their individually signed requests within a single transaction, a new signature must be obtained every time multiple requests are batched, and each implementation must separately guarantee that refunds are correctly linked to the original payment and that duplicate records or over-refunding do not occur. This drives up cost and trust issues in high-volume micropayment scenarios.
What to implement
event Flushed(address indexed institution, uint32 indexed statementId, uint96 debit, uint96 credit);: Occurs when an institution closes out its current statement, recording both amounts and the corresponding decrease in network state before resetting.function pay(PaymentRequest calldata request, PartyAuthorization[] calldata authorizations) external;: Verifies the three-party approval for an individual PaymentRequest and records the payment atomically.function batchPay(AuthorizedPayment[] calldata payments) external;: Atomically records multiple payments for the same pair of institutions at once, using the individual signatures already present on each item.function batchRefund(AuthorizedRefund[] calldata refunds) external;: Atomically records multiple refunds for the same pair of institutions at once, using the individual signatures already present on each item.function flush(address institution, uint32 expectedStatementId) external;: Closes out both sides of the institution's current statement, reduces the corresponding network balance, resets the institution's aggregates, and increments the statement number.function paymentNetwork() external view returns (address);: Returns the signing address of the Payment Network for this deployment.function currency() external view returns (string memory);: Returns the fixed, three-letter uppercase ASCII ISO 4217 currency code used by this deployment.function decimals() external view returns (uint8);: Returns the immutable number of decimal places used to express amounts in this deployment.function institutionState(address institution) external view returns (InstitutionState memory);: Returns the debit, credit, and statement number of an institution's current open statement; historical lookups are not provided.function networkState() external view returns (NetworkState memory);: Returns the payment network's current outstanding debit and credit aggregates; historical lookups are not provided.function paymentState(bytes32 paymentId) external view returns (bytes32);: Returns the single-slot state commitment for paymentId, keccak256(abi.encode(P, refundedAmount)); a value of 0 means it has not yet been recorded.function refundPaymentId(bytes32 refundId) external view returns (bytes32);: Returns the paymentId linked to a successfully recorded refundId; a value of 0 means that refundId has not yet been recorded.
In depth
Participant structure and three-party signature
Participants are divided into five roles: User, Merchant, Wallet (wallet institution), Acquirer (acquirer institution), and Payment Network. The onchain ledger (INanopaymentCore) verifies requests and three-party signatures, manages the institutionState/networkState accounts, and provides events and lookup functions. The off-chain fiat system performs the actual user debiting, refunds, inter-institution transfers, and merchant deposits, and reports the results independently. Each deployment identifies its payment network by the immutable signing address returned by paymentNetwork(), and the EIP-712 domain actually used for signature verification is exposed via ERC-5267's eip712Domain(). Interfaces or data models for institution onboarding, suspension, replacement, and assignment of Wallet/Acquirer roles are out of scope for this proposal. The payment network, paying institution, and receiving institution must each explicitly sign the same individual-typed request, and the caller's identity cannot substitute for a signature.
A three-party accounting model with four accounts
A transaction involves only three parties, the paying institution, the payment network, and the receiving institution, but there are four accounts. Each institution holds the debit and credit of its own statement in institutionState[institution], and the payment network holds its own debit and credit in a single networkState. pay(A) updates all four accounts together: institutionState[payerInstitution].debit += A, networkState.credit += A, networkState.debit += A, institutionState[payeeInstitution].credit += A. refund updates the same four accounts in the opposite direction (the original receiving institution becomes the paying side, and the original paying institution becomes the receiving side). flush closes out only one institution's statement independently, without touching the overall aggregates of other institutions or networkState. After every operation, the two invariants Σ institutionState[institution].debit = networkState.credit and networkState.debit = Σ institutionState[institution].credit always hold.
PaymentRequest / RefundRequest data structures
PaymentRequest consists of paymentId, payer, payerInstitution, payee, payeeInstitution, amount (uint96), and expiresAt (uint48), where paymentId is a globally unique identifier that must never be reused. RefundRequest consists of paymentId, refundId, amount, expectedRefundedAmount, and expiresAt, where refundId is a unique identifier linked to exactly one paymentId. PartyAuthorization is one party's signature, consisting of a party address and signature bytes. AuthorizedPayment bundles a request together with an authorizations array so it can be submitted either individually or included in a batch, and AuthorizedRefund additionally includes originalPayment.
pay/refund state commitment and signature verification
pay checks that paymentState(paymentId) is 0, then updates the four accounts and stores keccak256(abi.encode(P, uint96(0))), where P=hashStruct(PaymentRequest) (excluding the domain). refund recomputes P from the caller-supplied original PaymentRequest, checks that the current state matches keccak256(abi.encode(P, expectedRefundedAmount)) and that refundPaymentId(refundId) is 0, verifies that the refund amount does not exceed the original amount minus the cumulative refunded amount, updates the state to keccak256(abi.encode(P, expectedRefundedAmount+amount)), and records refundPaymentId(refundId)=paymentId. Signature verification accepts both 65-byte standard signatures and ERC-2098's 64-byte signatures for signers without code, rejecting invalid v values, high s values, and recovery to the zero address; for signers with code it accepts only 0x1626ba7e from a read-only ERC-1271 call and does not fall back to ECDSA on failure. Account type and verification policy must be evaluated against execution-time state and must not be cached.
Batch processing in batchPay and batchRefund
The Batch array must not be empty, and each call may only contain requests for a single payer/payee pair. batchPay may not contain duplicate paymentIds within the array, and batchRefund may not contain duplicate paymentIds or refundIds. Each entry undergoes the same validation as an individual pay/refund, and only after every entry passes does it update the four accounts once with the summed total amount and record each entry's state and event in input order. Batches have no separate signature type or batch root, so already-valid, unexecuted, complete authorization requests can be freely added, removed, or reordered. If any single entry fails, the entire batch is reverted with no partial results.
flush and off-chain statement reconstruction
flush can only be called by the institution itself or by paymentNetwork(), requires expectedStatementId to equal the current currentStatementId, and can close even an empty statement. On success it records the current (debit, credit) as Flushed, sets networkState.credit -= debit and networkState.debit -= credit, zeroes that institution's debit and credit, and increments currentStatementId by 1. Core does not separately store historical snapshots or transaction lists, so off-chain systems must locate Flushed by (ledger, institution, statementId) and reconstruct the statement by collecting PaymentPosted/RefundPosted events in log order from the previous Flushed up to the current Flushed. Logs from the same deployment are ordered by (blockNumber, transactionIndex, logIndex); event coordinates are only for locating logs and must not be used as business idempotency keys.
Immutability of amount units and currency settings
currency() must always return an uppercase ASCII 3-letter ISO 4217 code, and the decimals() value must not change over the deployment's lifetime. Neither value can be changed via configuration, governance, or upgrades; changing the currency or precision requires a new deployment. amount, debit, credit, and cumulative refund amounts are all expressed in units of 10^-decimals(), and uint96 can represent up to 2^96-1 of the smallest unit. A uint32 statement counter can withstand flushing once per second for about 136 years, so currentStatementId, debit, and credit can all fit together into a single InstitutionState slot (224 bits).
A proposal still in Draft stage
This proposal currently has status Draft, and no compliant reference implementation of the generalized four-account model has yet been provided. No gas cost figures have been presented either. The detailed interfaces and rules may change or be discontinued during discussion.
Things to watch out for
- A change in relationship does not block an already-signed request: Core cannot block execution of an already-signed request even after a customer relationship has changed, so institutions must verify the relationship themselves before signing, and EOA institutions without a dynamic revocation mechanism must rely primarily on a short expiresAt window.
- Signature verification must be based on execution-time state: An account's code, ownership, and verification policy can change, so caching the EOA/contract classification or falling back to ECDSA after an ERC-1271 verification failure can bypass a smart account's policy.
- refund must re-verify the original payment's state commitment: The caller-supplied original PaymentRequest and amount cannot be trusted; without first checking that they match the currently stored state commitment, the refund target could be swapped or the refundable amount inflated.
- A success event does not mean fiat processing has completed: Reorgs, duplicate event consumption, and uncertain responses can all cause incorrect or duplicate fund movements, so when a chain reorg is detected, funds must not be moved again immediately and must instead go through exception handling.
- Amounts and addresses are public data: Amounts, accounts, and institution addresses are all public, and this version provides no privacy guarantee, so KYC identity information must not be included in requests or events.