Comparing Gas Consumption of Safe 4337 Accounts on Arbitrum and Optimism
Over the past few weeks, we have been running an experiment to compare the gas consumption of creating a Safe 4337 account on the Arbitrum and Optimism blockchain networks. The results were surprising, as there were significant differences in gas costs between the two platforms.
The Experiment
To create a Safe 4337 account, we used the Safe 4337 wallet protocol, which allows users to interact with various contracts without revealing their private keys. I then set up both the Arbitrum and Optimism accounts on my computer and implemented a simple contract that created an account with a balance of one Ether (ETH). The implementation process was identical for both platforms.
Gas Cost
We collected gas usage data from 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 on Gwei |
As you can see, the gas price for creating a 4337 secure account on Optimist was about 25% higher than on Arbitrum.
The Reason for the Difference
To understand why this difference exists, we analyzed the contracts deployed on both chains and their interactions with each other. A major factor contributing to this discrepancy is the use of gas-intensive contract interactions between identical/similar contracts on different platforms.
On Optimist, many popular contracts such as 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 layer of abstraction.
Conclusion
These results suggest that setting up a secure 4337 account on Optimist can be significantly cheaper than on Arbitrum. As scalability and cost-efficiency requirements increase, it is important to consider these differences when choosing between different blockchain networks.
While Optimist is becoming more popular with users who need more advanced use cases or lower gas costs, Arbitrum remains an attractive option for those who need a simple, high-performance 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(string):
response = requests.get(f"
gas_price = int(response.text.strip().split("GasPrice:")[1].split(";")[0])
return gas_price / 100000000
Convert Gwei to ETH on Gwei
Implement a contract on Arbitrum and Optimistfrom safe_4337 import SafeContract, Account
contract = SafeContract()
account = account()
balance = account.create_initial_balance()
arbitrum_gas_price = get_gas_price("Arbitrum")
optimistic_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 various factors such as network congestion, smart contract complexity, and transaction frequency. Always consult a trusted blockchain resource or expert before making any decisions regarding the implementation of your application.