The
pay
function is the core method of Base Pay that lets your users send USDC (digital dollars) on the Base network. No crypto knowledge required - we handle all the complexity. No fees for merchants or users.Try it out: Test the pay
function interactively in our Base Pay SDK Playground.Parameters
Amount of USDC to send (e.g., “10.50” or “0.01”).
Ethereum address to send USDC to (must start with 0x).Pattern:
^0x[0-9a-fA-F]{40}$
Set to true to use Base Sepolia testnet instead of mainnet. Default: false
Optional payer information configuration for data callbacks.
Returns
Payment result on success. The function throws an error on failure.
Errors
Thepay
function throws an error when the payment fails. The error object contains a message explaining what went wrong.
Error Handling
Thepay
function throws errors instead of returning a result. Always wrap calls to pay
in a try-catch block to handle errors gracefully: