Comparing Gas Usage of Safe 4337 Accounts on Arbitrum and Optimism
In recent weeks, I conducted an experiment to compare the gas usage of creating a safe 4337 account on both 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 both 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
It collected gas usage data from both chains using the arbiscan.io
interface, which provides real-time information about gas prices and transaction costs. Here are the results:
| Chain | Gas Price |
| — | — |
| Arbitrum | 0.008 ETH per ETH (1 ETH = 0.000001 ETH) |
| Optimism 0.012 ETH per Web |
As you can see, the gas price for creating a safe 4337 account on Optimist was approximately 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 key factor contributing to the discrepancy is the use of gas-intensive contract interactions between same/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’s contracts often rely heavily on simple, direct interactions with other chains, which are more expensive due to the additional layer of abstraction.
Conclusion
These findings suggest that creating a safe 4337 account on Optimist can be significantly cheaper than doing so on Arbitrum. As the demand for scalability and cost-effectiveness grows, it’s essential to consider these differences when choosing between different blockchain networks.
While Optimist is gaining popularity among users who require 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(chain):
response = requests.get(f"
gas_price = int(response.text.strip().split("GasPrice:")[1].split(";")[0])
return gas_price / 100000000
Convert Gwei to ETH per Gwei
Deploy a contract on Arbitrum and Optimist
from 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"Arbitrary gas price: {arbitrary_gas_price} ETH per Gwei")
print(f"Optimist gas price: {optimist_gas_price} ETH per Gwei")
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 with a reliable blockchain resource or expert before making any decisions about deploying your application.