feat: add Gasless USDC Payments demo (EIP-3009 transferWithAuthorization) - #136
Open
osr21 wants to merge 3 commits into
Open
feat: add Gasless USDC Payments demo (EIP-3009 transferWithAuthorization)#136osr21 wants to merge 3 commits into
osr21 wants to merge 3 commits into
Conversation
Author
End-to-end test results — Base Sepolia ✅I exercised the relay endpoint against Base Sepolia before this review. One bug was found and fixed in this PR: the EIP-712 domain name. Bug fixed: EIP-712
|
| Test | Result |
|---|---|
| Happy path: 0.01 USDC transfer on Base Sepolia | ✅ confirmed on-chain |
Expired validBefore |
✅ rejected before submission |
validBefore > 1-hour cap |
✅ rejected before submission |
| Malformed nonce (< 32 bytes) | ✅ rejected before submission |
Smart-contract sender (EOA check via getCode) |
✅ detected and would reject |
Successful transfer tx: 0x1480796...7428ea — block 45518363, Base Sepolia
TypeScript compiles clean (tsc --noEmit, no errors).
Base Sepolia testnet USDC returns name() = "USDC", not "USD Coin". Using the wrong name causes FiatTokenV2: invalid signature on Sepolia. - Add usdcName to each NETWORKS entry - Update usdcDomain() to accept name as a parameter Verified on Base Sepolia: tx 0x148079622924611868790ee3997098cb82494813894ccd62b93a89420b7428ea (block 45518363)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a minimal, runnable demo of gasless USDC transfers on Base using EIP-3009
transferWithAuthorization, underapps/gasless-usdc-payments/:pages/index.tsx— connect an EOA wallet, sign the EIP-712TransferWithAuthorizationtyped data (no ETH needed), POST to the relay endpointpages/api/relay.ts— validates the authorization and submits it onchain, paying gaslib/eip3009.ts— USDC domain/types/addresses for Base + Base SepoliaAlso adds a row to the root README demo table.
Why
"User has USDC but no ETH" is one of the most common onboarding walls on Base, and EIP-3009 is the canonical answer for EOA wallets — yet there's no demo of the pattern in this repo (the paymaster demos cover contract-wallet sponsorship, not EOA authorization relaying). This distills the pattern we run in production at BasePay into the smallest correct example.
Deliberate design choices
validBeforeis capped at 1 hour server-side — signed authorizations are bearer instruments; the demo teaches the cap rather than leaving it to a footnote.getCodecheck) with an actionable error, because EIP-3009 signatures can't come from ERC-4337/ERC-1271 accounts and the alternative (letting it revert at submission) wastes the user's signature and the relayer's gas. This is the single most common integration failure we've seen with this pattern.authorization is used, etc.) are surfaced to the client.Testing
The signing payload, domain values, and relay flow are distilled from the EIP-3009 relayer we run in production at BasePay on Base mainnet (same domain/types/ABI, same validation checklist). This extracted demo has been reviewed for correctness against that implementation but not yet exercised end-to-end on Base Sepolia as a standalone app — happy to record a run-through or add adjustments if maintainers want changes to structure or dependencies first.