Sitemap
The Coinbase Blog

Learn about working at Coinbase: https://www.coinbase.com/careers

USDC payment processing in Coinbase Commerce

10 min readAug 14, 2019

--

Table of Contents

A customer paying with USDC using Coinbase Commerce’s point of sale

How Coinbase Commerce works — 30k foot overview

diagram explaining the life-cycle of a charge
This chart represents the life-cycle of a charge where Coinbase Commerce generates unique addresses for each charge. Once a payment is detected on the blockchain, Coinbase Commerce detects it and sends the appropriate notifications.

Non-custodial by design

diagram representing a withdrawal flow
The Coinbase Commerce servers never have access to the private keys (ie. mnemonic). All sensitive actions are performed locally on the merchant’s device. Only signed transactions are sent back to the servers for broadcasting to the blockchain.

Naïve solution — Forwarding contracts

diagram explaining the life-cycle of a naïve ERC20 payment forwarding
The life-cycle of a naïve ERC20-based payment flow. We eagerly deploy Forwarders that can later be used in charges. Once a Forwarder receives tokens, anyone (in this case Coinbase Commerce) can call its flush function to move the funds to the final destination and finalize the funds movement.

Reducing transaction sizes

Invoking Factory’s initForwarder deploys a Forwarder at a fraction of the cost.

Optimizing for off-chain whenever possible

create2 gives control over the addresses of the deployed Forwarders. The callers can now calculate the address of the Forwarder a priori, without knowing anything about the current blockchain state.
Including the contract’s bytecode in the create2 address calculation is a crucial safety feature. It ensures that the intended contract is the only one that can ever be deployed at the calculated address.

Minimizing deployment costs

The Factory can now create clones, which are light-weight alternatives to Forwarders. Particular care needs to be taken to the initialization of the clones.
diagram showing the final architecture of the smart contracts
This chart shows the final architecture of the forwarding contracts. Each merchant has their dedicated Forwarder (initialized with their destination), and a number of Forwarder clones (each clone associated with a particular charge). The contracts can be deployed (blue) or not deployed (yellow), but we can still safely calculate and use their addresses.

--

--

Responses (10)