Skip to content

Commit 9b6def0

Browse files
authored
Merge pull request #7 from eth-infinitism/paymaster_signature_doc
Add documentation for the paymaster signature field
2 parents ee587cc + e79a481 commit 9b6def0

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- [Security And Griefing](paymasters/security-and-griefing.md)
2323
- [Design Patterns](paymasters/design-patterns.md)
2424
- [Examples And SDKs](paymasters/examples-and-sdks.md)
25+
- [New: Paymaster Signature](paymasters/paymaster-signature.md)
2526

2627
- [⛓️ L2s](l2s/)
2728
- [README](l2s/README.md)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Paymaster Signature
2+
3+
## Feature overview
4+
5+
Starting with ERC-4337 version 0.9,
6+
it is possible to include a paymaster signature in the `paymasterAndData` field of the `PackedUserOperation`.
7+
8+
This paymaster signature is not included when calculating the `UserOperation` hash, same as the `signature` field,
9+
which allows for the Account and the Paymaster to sign the rest of the `UserOperation` in parallel.
10+
11+
## Generating a Paymaster Signature
12+
13+
1. Create a `paymasterAndData` bytes array as usual.
14+
2. Append the `PAYMASTER_SIG_MAGIC` (`0x22e325a297439656`) signature marker to the end of the `paymasterAndData` array.
15+
3. Build the rest of the `UserOperation` and send it for signing to the Account and the Paymaster services in parallel.
16+
4. Set the `signature` field of the `UserOperation` to the result of the Account signature as usual.
17+
5. Calculate the size of the Paymaster Signature and store it in a `uint16 paymasterSignatureSize` variable.
18+
6. Set the `paymasterSignature` field of the `UserOperation` to exactly `abi.encodePacked(paymasterAndData, paymasterSignatureSize, PAYMASTER_SIG_MAGIC)`.
19+
20+
## Summary of `paymasterAndData` format
21+
22+
The `paymasterAndData` field in its most complex form is a byte array with the following format:
23+
24+
```
25+
paymasterAddress(20) || verificationGasLimit(16) || postOpGasLimit(16) || paymasterData ||
26+
paymasterSignature || paymasterSignatureSize(2) || PAYMASTER_SIG_MAGIC (0x22e325a297439656)`
27+
```

0 commit comments

Comments
 (0)