Paymaster Signature¶
Feature overview¶
Starting with ERC-4337 version 0.9,
it is possible to include a paymaster signature in the paymasterAndData field of the PackedUserOperation.
This paymaster signature is not included when calculating the UserOperation hash, same as the signature field,
which allows for the Account and the Paymaster to sign the rest of the UserOperation in parallel.
Generating a Paymaster Signature¶
- Create a
paymasterAndDatabytes array as usual. - Append the
PAYMASTER_SIG_MAGIC(0x22e325a297439656) signature marker to the end of thepaymasterAndDataarray. - Build the rest of the
UserOperationand send it for signing to the Account and the Paymaster services in parallel. - Set the
signaturefield of theUserOperationto the result of the Account signature as usual. - Calculate the size of the Paymaster Signature and store it in a
uint16 paymasterSignatureSizevariable. - Set the
paymasterSignaturefield of theUserOperationto exactlyabi.encodePacked(paymasterAndData, paymasterSignatureSize, PAYMASTER_SIG_MAGIC).
Summary of paymasterAndData format¶
The paymasterAndData field in its most complex form is a byte array with the following format:
paymasterAddress(20) || verificationGasLimit(16) || postOpGasLimit(16) || paymasterData ||
paymasterSignature || paymasterSignatureSize(2) || PAYMASTER_SIG_MAGIC (0x22e325a297439656)`