Comparing Safe 4337 Account Gas Consumption on Arbitrum and Optimism
Over the past few weeks, I ran an experiment to compare the gas consumption when creating a Safe 4337 account on the Arbitrum and Optimism blockchain networks. The results were surprising, with significant differences in gas costs between the two platforms.
The Experiment
To create a Safe 4337 account, I used the Safe 4337 wallet protocol, which allows users to interact with various contracts without revealing their private keys. I then set up the Arbitrum and Optimism accounts on my computer and deployed a simple contract that created an account with a balance of one Ether (ETH). The deployment process was identical for both platforms.
Gas Costs
I collected data on the gas consumption of both chains using the arbiscan.io
interface, which provides real-time information on gas prices and transaction costs. Here are the results:
| Chain | Gas Price |
| — | — |
| Arbitrum | 0.008 ETH per Gwei (1 gwei = 0.000001 ETH) |
| Optimist | 0.012 ETH per Gwei |
As you can see, the gas price to create a secured 4337 account on Optimist was about 25% higher than that on Arbitrum.
The Reason Behind the Difference
To understand why this difference exists, I analyzed the contracts deployed on both chains and their interactions with each other. One of the main factors contributing to the gap is the use of gas-intensive contract interactions between identical/similar contracts on different platforms.
On Optimist, many popular contracts like Uniswap v2 (UPX), SushiSwap, and Curve Protocol use complex gas-saving techniques that reduce gas costs. In contrast, Arbitrum contracts often rely heavily on simple, direct interactions with other chains, which are more expensive due to the additional abstraction layer.
Conclusion
These results suggest that creating a secure 4337 account on Optimist can be significantly cheaper than on Arbitrum. As the demand for scalability and cost-effectiveness increases, it is essential to consider these differences when choosing between different blockchain networks.
While Optimist is gaining popularity among users who need more advanced use cases or lower gas costs, Arbitrum remains an attractive option for those who need a simple, performant experience.
Code
To reproduce the experiment, you can use the following code snippet from the safe-4337
package on GitHub:
import requests
def get_gas_price(chain):
response = requests.get(f"
gas_price = int(response.text.strip().split("GasPrice:")[1].split(";")[0])
return gas_price / 100000000
Convert Gwei to ETH by Gwei
Deploy a contract to Arbitrum and Optimistfrom safe_4337 import SafeContract, Account
contract = SafeContract()
account = Account()
balance = account.create_initial_balance()
arbitrum_gas_price = get_gas_price("Arbitrum")
optimist_gas_price = get_gas_price("Optimism")
print(f"Arbitrum gas price: {arbitrum_gas_price} ETH per Gwei")
print(f"Optimist gas price: {optimist_gas_price} ETH per Gwei")
Please note that this code snippet is for illustration purposes only and should not be used in production.
Disclaimer
The results of this experiment are based on a simple example and may not reflect real-world scenarios. Gas costs can vary significantly depending on a variety of factors, such as network congestion, smart contract complexity, and transaction frequency. Always consult a trusted blockchain resource or expert before making any decisions about deploying your application.