Skip to content

feat(evm): implement ERC-7710 delegation support in exact facilitator#22

Open
rockorama wants to merge 2 commits intocoinbase:mainfrom
rockorama:feat/erc7710-facilitator
Open

feat(evm): implement ERC-7710 delegation support in exact facilitator#22
rockorama wants to merge 2 commits intocoinbase:mainfrom
rockorama:feat/erc7710-facilitator

Conversation

@rockorama
Copy link
Copy Markdown

Add verifyERC7710 and settleERC7710 alongside the existing EIP-3009 and Permit2 implementations, completing the three asset transfer methods defined in specs/schemes/exact/scheme_exact_evm.md.

Description

ERC-7710 was fully specced in the repo but had zero TypeScript implementation. This PR closes that gap.

Changes:

  • src/types.ts: ExactERC7710Payload type, isERC7710Payload() guard, AssetTransferMethod extended with 'erc7710'
  • src/exact/facilitator/erc7710.ts: verifyERC7710 (field validation + eth_call simulation of redeemDelegations) and settleERC7710 (re-verify + writeContract + receipt wait). Calldata uses ERC-7579 packed format with SINGLE_CALL_MODE.
  • src/exact/facilitator/errors.ts: 5 new ERC-7710 error constants
  • src/exact/facilitator/scheme.ts: ERC-7710 branch in verify() and settle(), checked first
  • src/exact/facilitator/erc7710.test.ts: full unit test coverage
  • typescript/.changeset/erc7710-delegation-support.md: changeset fragment (@x402/evm minor)

Spec ref: specs/schemes/exact/scheme_exact_evm.md §3
Note: verification is simulation-only per spec design. Gas limit should be set by callers per spec security recommendation.

Tests

pnpm test --filter @x402/evm

Checklist

  • Formatted (prettier applied)
  • Unit tests added
  • Changeset fragment added
  • Commits need signing — happy to rebase with GPG if required

@Bortlesboat
Copy link
Copy Markdown

Pulled this locally and pnpm --filter @x402/evm test is red for me on the new erc7710.test.ts cases. The implementation normalizes delegationManager through getAddress(), so the assertions that expect the lowercase fixture address don't match the checksummed address passed to readContract / writeContract.

One other thing I wanted to sanity-check: verifyERC7710() simulates redeemDelegations via signer.readContract(...), but FacilitatorEvmSigner.readContract can't currently take an account, and a few existing integrations/examples wire it to publicClient.readContract(...) rather than a wallet client. ERC-7710 says redeemDelegations executes "if the caller has authority to do so", so should verification be simulating as the facilitator address that will actually settle? Otherwise verify/settle could diverge for caller-sensitive delegation managers.

@Bortlesboat
Copy link
Copy Markdown

I put together the follow-up patch here in case it's useful to cherry-pick or merge directly into this branch: rockorama#1

It keeps the scope tight to the two things that came up in local validation:

  • preserve facilitator caller context during ERC-7710 verify simulation
  • fix the brittle ERC-7710 test assertions around normalized addresses

@rockorama
Copy link
Copy Markdown
Author

Thanks for the quick follow-up and for taking the time to pull this locally and validate! The caller context fix is the right call, good catch on the redeemDelegations simulation needing to run as the actual facilitator. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants