This repo contains a verifying paymaster contract that can be used for gas subsidies for ERC-4337 transactions.
It contains a clone of the eth-infinitism VerifyingPaymaster with an additional receive()
function for simple deposits, as well as some additional changes made in response to an audit.
(More coming soon)
Network | Address |
---|---|
Base Sepolia | 0xf5d253B62543C6Ef526309D497f619CeF95aD430 |
If you'd like to use the paymaster to sponsor your 4337 user operations, follow these steps:
eth_paymasterAndDataForEstimateGas
JSON-RPC method on https://paymaster.base.org. Parameters:
Object
- the unsigned user operationstring
- the address of the entrypoint contractstring
- the chain ID, in hexadecimal
curl "https://paymaster.base.org" \
-H 'content-type: application/json' \
-d '
{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_paymasterAndDataForEstimateGas",
"params": [
{
"sender": "0x0000000000000000000000000000000000000000",
"nonce": "0x2a",
"initCode": "0x",
"callData": "0x",
"callGasLimit": "0x1",
"verificationGasLimit": "0x1",
"preVerificationGas": "0x1",
"maxFeePerGas": "0x1",
"maxPriorityFeePerGas": "0x1"
},
"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
"0x14A34"
]
}
'
paymasterAndData
field in the userOp for gas estimation in step 4.
Note that this is a dummy signature that won't be accepted by the paymaster, except for gas estimation.
If an error is returned or the result is empty, the paymaster is not available for the given operation or chain. You can stop here and choose to proceed with another paymaster or self-funding the user operation.op.PreVerificationGas = estimate.PreVerificationGas + 2000
op.VerificationGasLimit = estimate.VerificationGasLimit + 4000
eth_paymasterAndDataForUserOperation
JSON-RPC method on https://paymaster.base.org. Parameters:
Object
- the unsigned user operationstring
- the address of the entrypoint contractstring
- the chain ID, in hexadecimal
curl "https://paymaster.base.org" \
-H 'content-type: application/json' \
-d '
{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_paymasterAndDataForUserOperation",
"params": [
{
"sender": "0x0000000000000000000000000000000000000000",
"nonce": "0x2a",
"initCode": "0x",
"callData": "0x",
"callGasLimit": "0x1",
"verificationGasLimit": "0x1",
"preVerificationGas": "0x1",
"maxFeePerGas": "0x1",
"maxPriorityFeePerGas": "0x1"
},
"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
"0x14A34"
]
}
'
paymasterAndData
field in the userOp.
If an error is returned or the result is empty, the paymaster is not available for the given operation or chain. You can choose to proceed with another paymaster or self-funding the user operation.Note that the paymasterAndData
returned in step 6 contains a signature of the provided userOp, so any modification of the userOp post step 6 (except for the sig
field) will result in the paymaster rejecting the operation.
If you want to deploy your own paymaster, you can deploy Paymaster.sol to your chain of choice.
In order to generate signatures for your paymaster, there's a Golang package in the signer directory that allows you to sign userOperations that will be accepted by the paymaster (call UserOperation.PaymasterSign
).
Of course you can also rewrite this in your language of choice; the Golang package will provide a good example.