Paymaster 调研
ERC7677
https://www.erc7677.xyz/guides/construct-user-op-with-7677
Paymaster Services
核心API
- pm_getPaymasterStubData
用于预估含有paymaster的userOp的Gas estimates https://www.erc7677.xyz/getting-started#getting-started
- pm_getPaymasterData
user operation 中 paymasterData 字段 Paymaster 服务必须检测正在使用的 EntryPoint 版本,并根据检测到的 EntryPoint 版本处理和响应请求
stackup-paymaster 代码中,没有提供上述两个rpc,可以参考 PaymasterAndData的生成过程
Pm_sponsorUserOperation
参考代码
V6 https://github.com/pimlicolabs/erc7677-proxy/blob/a2f3f85f2fd8232847ca1c71091320f9dddd57ef/src/app.ts#L79-L131 V7 https://github.com/pimlicolabs/erc7677-proxy/blob/a2f3f85f2fd8232847ca1c71091320f9dddd57ef/src/app.ts#L133-L184
Paymaster service providers that support ERC-7677
https://www.erc7677.xyz/ecosystem/paymasters
- Coinbase Developer Platform
- Pimlico
- ZeroDev
- Biconomy
- permissionless.js
Viem 代码实现
通过 createPaymasterClient 创建 PaymasterClient 调用 Paymaster Services 两个rpc方法
https://viem.sh/account-abstraction/actions/paymaster/getPaymasterData
https://viem.sh/account-abstraction/actions/paymaster/getPaymasterStubData
在viem prepareUserOperation api 中有具体根据userOp中paymaster(多种数据类型)相关字段信息调用 viem getPaymasterStubData 、getPaymasterData 实现过程
见viem:
- https://github.com/wevm/viem/blob/0463e1d4de7cd35e2e9604890ee32b37a2775864/src/account-abstraction/actions/bundler/prepareUserOperation.ts#L506-L521
- https://github.com/wevm/viem/blob/0463e1d4de7cd35e2e9604890ee32b37a2775864/src/account-abstraction/actions/bundler/prepareUserOperation.ts#L539-L540
Paymaster 合约
https://docs.pimlico.io/infra/paymaster/verifying-paymaster
https://docs.pimlico.io/infra/paymaster/erc20-paymaster
https://github.com/pimlicolabs/erc20-paymaster/blob/main/src/ERC20PaymasterV06.sol
https://github.com/pimlicolabs/erc20-paymaster/blob/main/src/ERC20PaymasterV07.sol