// [userOp, entryPoint, chainId, context]typeGetPaymasterStubDataParams=[// Below is specific to Entrypoint v0.6 but this API can be used with other entrypoint versions too{sender:`0x${string}`;nonce:`0x${string}`;initCode:`0x${string}`;callData:`0x${string}`;callGasLimit:`0x${string}`;verificationGasLimit:`0x${string}`;preVerificationGas:`0x${string}`;maxFeePerGas:`0x${string}`;maxPriorityFeePerGas:`0x${string}`;},// userOp`0x${string}`,// EntryPoint`0x${string}`,// Chain IDRecord<string,any>// Context];typeGetPaymasterStubDataResult={sponsor?:{name:string;icon?:string};// Sponsor infopaymaster?:string;// Paymaster address (entrypoint v0.7)paymasterData?:string;// Paymaster data (entrypoint v0.7)paymasterVerificationGasLimit?:`0x${string}`;// Paymaster validation gas (entrypoint v0.7)paymasterPostOpGasLimit?:`0x${string}`;// Paymaster post-op gas (entrypoint v0.7)paymasterAndData?:string;// Paymaster and data (entrypoint v0.6)isFinal?:boolean;// Indicates that the caller does not need to call pm_getPaymasterData};
返回用于已签名用户操作的 paymaster 相关字段中的值。这些不是存根值,将在用户操作提交到 bundler 期间使用。与 pm_getPaymasterStubData 类似,接受未签名的用户操作、入口点地址、链 ID 和上下文对象。
pm_getPaymasterData RPC 规范
请注意,用户操作参数不包括签名,因为用户在填充所有其他字段后签名。
// [userOp, entryPoint, chainId, context]typeGetPaymasterDataParams=[// Below is specific to Entrypoint v0.6 but this API can be used with other entrypoint versions too{sender:`0x${string}`;nonce:`0x${string}`;initCode:`0x${string}`;callData:`0x${string}`;callGasLimit:`0x${string}`;verificationGasLimit:`0x${string}`;preVerificationGas:`0x${string}`;maxFeePerGas:`0x${string}`;maxPriorityFeePerGas:`0x${string}`;},// userOp`0x${string}`,// Entrypoint`0x${string}`,// Chain IDRecord<string,any>// Context];typeGetPaymasterDataResult={paymaster?:string;// Paymaster address (entrypoint v0.7)paymasterData?:string;// Paymaster data (entrypoint v0.7)paymasterAndData?:string;// Paymaster and data (entrypoint v0.6)};
当前 paymaster 服务的宽松标准是实现 pm_sponsorUserOperation。此方法返回 paymaster 相关用户操作字段的值和更新的 gas 值。此方法的问题在于 paymaster 服务提供商具有不同的 gas 估计方式,这导致不同的估计 gas 值。有时这些估计可能不足。因此,我们认为最好将 gas 估计留给钱包,因为钱包具有更多关于用户操作如何提交的上下文(例如,它们将被提交给哪个 bundler)。然后,钱包可以要求 paymaster 服务赞助给定的由钱包定义的估计值。
上述原因也是我们指定 pm_getPaymasterStubData 方法也可以返回 paymaster 特定的 gas 估计值的原因。也就是说,bundler 容易对 paymaster 特定的 gas 值进行不充分的估计,而 paymaster 服务本身最终更适合提供它们。
链 ID 参数
目前,paymaster 服务提供商通常为开发人员提供每个链的 URL。也就是说,paymaster 服务 URL 通常不是多链的。那么为什么我们需要链 ID 参数?我们认识到我们必须指定一些约束,以便钱包可以与 paymaster 服务通信关于其请求是针对哪个链的。正如我们所看到的,有两种选择:
在简单的情况下,与最终值长度相同的重复非零字节(例如 0x01)的存根值将生成可用的 preVerificationGas。虽然这会立即导致 gas 估计错误,因为模拟可能会由于无效的 paymaster 数据而恢复。
在更实际的情况下,有效的存根可能会导致模拟成功,但仍然返回不足的 gas 限制。如果存根数据导致 validatePaymasterUserOp 或 postOp 函数模拟与最终值不同的代码路径,则可能会发生这种情况。例如,如果模拟的代码要提前返回,则估计的 gas 限制将低于预期,这将导致一旦将用户操作提交给 bundler,上游就会出现 out of gas 错误。