Signing User Operations

Signing user operations is dependent on the smart account

The signature field

ERC-4337 allows the signature field of a user operation to be any data, so generating the signature of a user operation will be dependent on your smart account.

However, most of the time smart accounts will simply sign over the user operation hash. If an ethers.js Signer object is used, you can simply use the signMessage function.

const signature = signer.signMessage(

The userOpHash is the hash of the user operation. Learn how to get the userOpHash.

Signing Paymasters

Many types of paymasters, including Stackup's paymasters, need to sign a user operation and include the signature in the user operation's paymasterAndData.

Even though the user operation is not signed by the user yet, the paymaster still needs to make an estimate of how much gas the user operation will take. To do this, a dummy signature will need to be included in the gas estimate.

If you are using a userop.js preset, this logic is already handled for you. You can see an example of a dummy signature in the userop.js code.

Checking the smart account's signature method

If your application does not already know what smart account is being used by the user, you will need to check the signature logic on-chain.