Skip to content

Conversation

@TaprootFreak
Copy link
Collaborator

Summary

  • Add PaymasterModule with ERC-7677 JSON-RPC endpoints (pm_getPaymasterStubData, pm_getPaymasterData)
  • Add deposit address validation to only sponsor transfers to DFX deposit addresses
  • Update sell.service.ts and swap.service.ts to set usePaymaster and paymasterUrl fields when user has 0 gas
  • Update UnsignedTxDto with new Paymaster fields
  • Add isValidDepositAddress method to DepositService

Context

The original EIP-7702 implementation using manual eth_sign is broken because MetaMask disables eth_sign by default. This PR migrates to wallet_sendCalls (ERC-5792) with Paymaster sponsorship.

New Flow

User → Frontend (wallet_sendCalls) → MetaMask → Paymaster → Blockchain

MetaMask handles EIP-7702 internally, and the Paymaster sponsors gas for transactions to valid DFX deposit addresses.

Security

  • Paymaster validates that to address is a registered DFX deposit address
  • Only ERC-20 transfers to deposit addresses are sponsored
  • Rejects all other transactions

Dependencies

Test plan

  • Build passes
  • Paymaster endpoint responds to ERC-7677 requests
  • Deposit address validation works correctly
  • E2E test with MetaMask wallet_sendCalls

Migrate EIP-7702 from manual signing (broken due to eth_sign disabled in MetaMask)
to wallet_sendCalls with Paymaster sponsorship.

Changes:
- Add PaymasterModule with ERC-7677 JSON-RPC endpoints (pm_getPaymasterStubData, pm_getPaymasterData)
- Add deposit address validation to only sponsor transfers to DFX deposit addresses
- Update sell.service.ts and swap.service.ts to set usePaymaster and paymasterUrl fields
- Update UnsignedTxDto with new Paymaster fields
- Add isValidDepositAddress method to DepositService

The Paymaster validates that transactions are only to valid DFX deposit addresses,
preventing abuse of gas sponsorship.
- PaymasterService tests (20 tests):
  - pm_getPaymasterStubData and pm_getPaymasterData handling
  - Chain validation (Ethereum, Arbitrum, Base, Sepolia, etc.)
  - Transfer recipient extraction (ERC20, ERC-7579)
  - Deposit address validation
  - Error handling

- PaymasterController tests (8 tests):
  - Request/response passthrough
  - Chain ID parameter handling
  - Error propagation
@TaprootFreak
Copy link
Collaborator Author

Closing: Implementation requires Pimlico integration (or similar ERC-4337 paymaster provider) to function. Current backend is a stub that won't work with MetaMask's wallet_sendCalls.

See analysis: services/docs/PIMLICO-PAYMASTER-ANALYSIS.md

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants