eth_sendUserOperation

Sends a user operation to the given EVM network.

Network Support

ChainMainnetTestnet
Ethereum:white-check-mark::white-check-mark:
Polygon:white-check-mark::white-check-mark:
Arbitrum:white-check-mark::white-check-mark:
Optimism:white-check-mark::white-check-mark:
Base:white-check-mark::white-check-mark:
Frax:white-check-mark::white-check-mark:
Zora:white-check-mark::white-check-mark:

Choosing an Entry Point Version

eth_sendUserOperation supports versions v0.6 and v0.7 of ERC-4337. These two versions define different formats for user operations, and their entry point contracts are deployed at different addresses. Thus, when calling eth_sendUserOperation, you must choose whether you want to use the v0.6 or v0.7 version of this endpoint and ensure that you are using the correct user operation format and entry point address for that version.

Which version you want is determined by the smart contract account for which you are trying to send a user operation. A given smart contract account will typically be written to be compatible with either v0.6 or v0.7 and you should use that version in your request. If you're not sure which version is compatible with a smart contract account, you can look at its source code and check the first parameter to validateUserOp. If it has type UserOperation, then the account uses v0.6, while if it has type PackedUserOperation then the account uses v0.7.

For more information about the differences in versions, see the specifications for ERC-4337 v0.6.0 and ERC-4337 v0.7.0, particularly the description of the user operation fields.

Replacement Underpriced Error

You might get a "Replacement Underpriced Error" when using eth_sendUserOperation. This error occurs when a user already has an existing operation in the mempool. User operations can become "stuck" in the mempool if their gas fee limits are too low to be included in a bundle.

To resolve this, the user must increase both maxFeePerGas and maxPriorityFeePerGas by at least 10%.

📘

maxFeePerGas vs. maxPriorityFeePerGas

The maxFeePerGas is the sum of the baseFeePerGas and maxPriorityFeePerGas. Learn the differences between maxFeePerGas vs. maxPriorityFeePerGas in our comparative article.

How to Resolve a Replacement Underpriced Error

  1. Re-estimate gas fees: Re-estimate the gas fees required for your operation. This can be done in various ways which are mentioned below:

    1. eth_maxPriorityFeePerGas: maxPriorityFeePerGas can be obtained using this method.
    2. getFeeData: This method on Alchemy SDK returns both the current maxPriorityFeePerGas and maxFeePerGas. This method is also available on web3 libraries like ethers.js and can be accessed through the provider as provider.getFeeData().
  2. Choose the suitable increase values: Once you have the re-estimated gas fees, choose the maximum of a 10% increase or the re-estimated values. This ensures that your new gas fee is competitively priced to be included in a block.

  3. Account for Rundler's service tip: Rundler requires a small tip for its services via maxPriorityFeePerGas. Detailed information about this can be found on the Bundler API Fee Logic page but in summary:

    • On Ethereum, Polygon, and Optimism mainnets, the tip should be at least 25% higher than the estimated priority fee on the network.

    • On Arbitrum / Optimism mainnet, the tip is set to a minimum 5% of the estimated network base fee when the bundle is mined.

    • No tip is required on testnets.

Now, send your userOperation again using the calculated values and it should go through successfully.

Language
URL
Click Try It! to start a request and see the response here!
ReadMe