|
1 | 1 | # Base paymaster
|
2 | 2 |
|
3 | 3 | This repo contains a verifying paymaster contract that can be used for gas subsidies for [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337) transactions.
|
4 |
| -It contains a clone of the [eth-infinitism VerifyingPaymaster](https://github.com/eth-infinitism/account-abstraction/blob/73a676999999843f5086ee546e192cbef25c0c4a/contracts/samples/VerifyingPaymaster.sol) with an additional `receive()` function for simple deposits. |
| 4 | +It contains a clone of the [eth-infinitism VerifyingPaymaster](https://github.com/eth-infinitism/account-abstraction/blob/73a676999999843f5086ee546e192cbef25c0c4a/contracts/samples/VerifyingPaymaster.sol) with an additional `receive()` function for simple deposits, as well as some additional changes made in response to an audit. |
5 | 5 |
|
6 | 6 | ### Deployments
|
7 | 7 |
|
8 | 8 | _(More coming soon)_
|
9 | 9 |
|
10 |
| -| Network | Address | |
11 |
| -|-------------|-----------------------------------------------------------------------------------------------------------------------------------| |
12 |
| -| Base Goerli | [0x88Ad254d5b1a95C9Bd2ae5F87E2BE27d95d86c2f](https://goerli-explorer.base.org/address/0x88Ad254d5b1a95C9Bd2ae5F87E2BE27d95d86c2f) | |
| 10 | +| Network | Address | |
| 11 | +|--------------|------------------------------------------------------------------------------------------------------------------------------------| |
| 12 | +| Base Goerli | [0x88Ad254d5b1a95C9Bd2ae5F87E2BE27d95d86c2f](https://goerli-explorer.base.org/address/0x88Ad254d5b1a95C9Bd2ae5F87E2BE27d95d86c2f) | |
| 13 | +| Base Sepolia | [0xf5d253B62543C6Ef526309D497f619CeF95aD430](https://sepolia-explorer.base.org/address/0xf5d253B62543C6Ef526309D497f619CeF95aD430) | |
13 | 14 |
|
14 | 15 | ### Obtaining a signature for use with the paymaster contract
|
15 | 16 |
|
16 | 17 | If you'd like to use the paymaster to sponsor your 4337 user operations, follow these steps:
|
17 | 18 |
|
18 |
| -1. Construct your user operation, without a paymaster set. |
19 |
| -2. (optional) Call estimate gas on your bundler of choice. |
20 |
| -3. Add some headroom to make room for the paymaster verification gas. In our testing we've found the following values work, but it would depend on your bundler: |
21 |
| - 1. `op.PreVerificationGas = estimate.PreVerificationGas + 2600` |
22 |
| - 2. `op.VerificationGasLimit = estimate.VerificationGasLimit + 16000` |
23 |
| -4. Call `eth_paymasterAndDataForUserOperation` JSON-RPC method on https://paymaster.base.org. Parameters: |
| 19 | +1. Construct your user operation, without a paymaster set, and left unsigned. |
| 20 | +2. Call `eth_paymasterAndDataForEstimateGas` JSON-RPC method on https://paymaster.base.org. Parameters: |
| 21 | + 1. `Object` - the unsigned user operation |
| 22 | + 2. `string` - the address of the entrypoint contract |
| 23 | + 3. `string` - the chain ID, in hexadecimal |
| 24 | +```shell |
| 25 | +curl "https://paymaster.base.org" \ |
| 26 | + -H 'content-type: application/json' \ |
| 27 | + -d ' |
| 28 | +{ |
| 29 | + "id": 1, |
| 30 | + "jsonrpc": "2.0", |
| 31 | + "method": "eth_paymasterAndDataForEstimateGas", |
| 32 | + "params": [ |
| 33 | + { |
| 34 | + "sender": "0x0000000000000000000000000000000000000000", |
| 35 | + "nonce": "0x2a", |
| 36 | + "initCode": "0x", |
| 37 | + "callData": "0x", |
| 38 | + "callGasLimit": "0x1", |
| 39 | + "verificationGasLimit": "0x1", |
| 40 | + "preVerificationGas": "0x1", |
| 41 | + "maxFeePerGas": "0x1", |
| 42 | + "maxPriorityFeePerGas": "0x1" |
| 43 | + }, |
| 44 | + "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", |
| 45 | + "0x14A33" |
| 46 | + ] |
| 47 | +} |
| 48 | +' |
| 49 | +``` |
| 50 | +3. Call estimate gas on your bundler of choice. |
| 51 | +4. Add some headroom to make room for the paymaster verification gas. In our testing we've found the following values work, but it would depend on your bundler: |
| 52 | + 1. `op.PreVerificationGas = estimate.PreVerificationGas + 2000` |
| 53 | + 2. `op.VerificationGasLimit = estimate.VerificationGasLimit + 4000` |
| 54 | +5. Call `eth_paymasterAndDataForUserOperation` JSON-RPC method on https://paymaster.base.org. Parameters: |
24 | 55 | 1. `Object` - the unsigned user operation
|
25 | 56 | 2. `string` - the address of the entrypoint contract
|
26 | 57 | 3. `string` - the chain ID, in hexadecimal
|
@@ -50,8 +81,8 @@ curl "https://paymaster.base.org" \
|
50 | 81 | }
|
51 | 82 | '
|
52 | 83 | ```
|
53 |
| -5. If the request is successful and the response contains a hex-encoded byte array, use that as the `paymasterAndData` field in the userOp. |
| 84 | +6. If the request is successful and the response contains a hex-encoded byte array, use that as the `paymasterAndData` field in the userOp. |
54 | 85 | 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.
|
55 |
| -6. Sign the user operation, and submit to your bundler of choice. |
| 86 | +7. Sign the user operation, and submit to your bundler of choice. |
56 | 87 |
|
57 | 88 | Note that the `paymasterAndData` returned in step 4 contains a signature of the provided userOp, so any modification of the userOp post step 4 (except for the `sig` field) will result in the paymaster rejecting the operation.
|
0 commit comments