You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 87e75e6
Browse filesBrowse the repository at this point in the historyBrowse files
New src/permit2.ts with viem actions and a permit2Actions() client
extension for the canonical Permit2 contract, covering both flows:
- SignatureTransfer: signPermit2Transfer (PermitTransferFrom, or
PermitWitnessTransferFrom with a witness), permit2TransferFrom for the
spender, isPermit2NonceUsed against the nonce bitmap, random nonces.
- AllowanceTransfer: signPermit2Allowance (PermitSingle, nonce read from
Permit2), permit2Permit, permit2AllowanceTransferFrom,
getPermit2Allowance.
- approvePermit2 / getPermit2Approval for the one-time ERC-20 approval.
The EIP-712 domain, type sets, witness hash and witness type string are
exported; the type string is derived with EIP-712's ordering rule and
tested against the x402 layout and viem's type hash.
Tests use the in-memory node from the ERC-20 change and recover every
signature to the owner. Examples: fresh-wallet reads the Permit2 approval
through the new action; permit2-pull.mjs signs a transfer off-chain and
pulls it from a second account.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D1P1hkDQJ1iTaqumjZWtg8
|`examples/agent-buyer`|`buy.mjs` (pay a URL), `fresh-wallet.mjs` (gasless proof from a new wallet) |
285
+
|`examples/agent-buyer`|`buy.mjs` (pay a URL), `fresh-wallet.mjs` (gasless proof from a new wallet), `permit2-pull.mjs` (sign a Permit2 transfer off-chain, pull it from another account)|
246
286
|`examples/demo-dapp`| Test-dapp style page exercising both sides in the browser (burner wallet or MetaMask) |
247
287
|`test/`| unit tests (facilitator and RPC mocked; `client-parity.test.ts` pins the wire format against radius-cli's; `balances.test.ts` runs the native-balance init code in a real EVM); `test/e2e` real settlement and a live balance reconciliation on testnet or mainnet (`RADIUS_E2E=1 RADIUS_PRIVATE_KEY=… [RADIUS_NETWORK=mainnet] pnpm test:e2e`) |
console.error(`payer ${payer.account.address} signed a permit for ${formatTokenAmount(signed.permit.permitted.amount,SBC)} to spender ${signed.spender}, nonce ${signed.permit.nonce}, deadline ${signed.permit.deadline}`);
27
+
console.error(`nonce used before pull: ${awaitcollector.isPermit2NonceUsed({owner: signed.owner,nonce: signed.permit.nonce})}`);
28
+
29
+
// 3. On-chain: the collector pulls the SBC to itself. It could also pull less than the permitted amount.
0 commit comments