calendar_today
October 14, 2024
October 14, 2024
|
schedule
5
min read
Gas Costs: EVM & Non-EVM Blockchains
No items found. Add items to cms.

Gas fees have long been a critical concern. When I deployed my first smart contract on Ethereum, the excitement was quickly tempered by the high gas costs involved. This led me to explore why gas fees are substantial on some platforms and how different blockchain architectures influence these costs.

Gas in EVM-Based Blockchains

Ethereum, as the pioneer of smart contracts, has seen immense growth. However, this popularity comes with a price. High demand leads to network congestion, which in turn drives up gas prices. During peak times, I’ve seen gas fees soar to levels that make small transactions impractical.

Ethereum, as an EVM blockchain, uses gas as a unit to measure the computational effort required to execute operations. Each operation in a smart contract consumes a specific amount of gas, proportional to its complexity and resource usage. Gas prices are denominated in gwei (a fraction of Ether) and fluctuate based on network demand.

https://www.bitflex.com/blog/understanding-ethereum-gas-fees/

For developers aiming to optimize gas costs on Ethereum, several strategies are essential:

  1. Storage minimization. Since writing to blockchain storage is expensive, developers should minimize state changes. Utilizing events for logging (which are cheaper) instead of storing data on-chain when possible can save gas.
  2. Optimizing function calls. Reducing the number of external contract calls and consolidating logic within a single contract can decrease gas usage due to lower call overhead.
  3. Data structures: Choosing the right data structures, such as mappings over arrays for certain use cases, can lead to gas savings due to more efficient access patterns.

Non-EVM Platforms (Solana and Sui):

Frustrated by Ethereum’s gas fees, I started exploring alternatives. Solana stood out with its high throughput and low fees. Built with Rust, Solana can handle thousands of transactions per second, thanks to innovations like Proof of History and parallel processing. Instead of gas fees that fluctuate with network demand, Solana charges minimal, predictable fees per transaction.

Working with Solana was a breath of fresh air. The network’s ability to process transactions concurrently without significant fees opens up possibilities that were challenging on Ethereum. By structuring transactions to minimize conflicts and leveraging Solana’s Sealevel runtime, developers can maximize throughput and efficiency. In practical terms, this means designing programs that operate on different accounts, allowing for parallel execution.

Sui offers another intriguing path. Developed using the Move programming language, Sui’s object-centric model allows for parallel transaction execution, enhancing scalability while keeping fees low. Move emphasizes safety, reducing the likelihood of common smart contract vulnerabilities. Understanding and applying resource management principles in Move leads to safe and efficient code, potentially lowering computational resources required.

When I started building on Sui, the focus on resource-oriented programming was a shift from Solidity, but it brought valuable benefits. The language enforces rules that safeguard against unintended asset manipulation, which not only improves security but can also contribute to reduced execution costs.

Impact

High gas fees don’t just affect developers, they hit users directly. During periods of network congestion on Ethereum, transaction costs can deter people from engaging with decentralized applications. I’ve seen firsthand how friends interested in blockchain technology became disillusioned after encountering steep fees for simple transactions.

Layer 2 solutions like Optimism aim to alleviate these issues by reducing fees and providing faster transaction finality within the Ethereum ecosystem. Optimism uses optimistic rollups to batch transactions off-chain, decreasing the load on the main network.

On the other hand, platforms like Solana and Sui offer low transaction fees and high scalability by design. Users benefit from quick confirmations and minimal costs, which is especially important for applications requiring high transaction volumes, such as gaming platforms or microtransactions. In one project, migrating to Solana allowed us to offer services that would have been cost-prohibitive on Ethereum.

Development & Tooling

Ethereum’s mature ecosystem is a significant advantage. Tools like Remix, Hardhat, and Truffle streamline smart contract development, testing, and deployment. The extensive libraries and community support make problem-solving more manageable. Optimism, being EVM-compatible, lets developers leverage these tools with minimal adjustments, easing the transition to a Layer 2 solution.

In contrast, developing on Solana requires proficiency in Rust and familiarity with tools like Solana CLI and the Anchor framework. Rust offers performance and safety benefits but has a steeper learning curve compared to Solidity. When I first delved into Rust, it was challenging but rewarding. The language’s emphasis on safety and concurrency aligns well with blockchain development.

Sui introduces the Move, which brings its own set of tools and paradigms. Move’s resource-oriented approach requires a different way of thinking, focusing on the safe management of assets. While the learning curve is there, the potential for writing secure and efficient code makes it worthwhile.

Security

Security is eveything blockchain development. Ethereum’s history has led to well-established best practices to mitigate vulnerabilities like reentrancy attacks and integer overflows. However, developers must remain vigilant.

Solana and Sui, with their emphasis on safe programming languages, offer inherent security advantages. Rust’s strict compile-time checks help prevent many low-level bugs. In my experience, the Rust compiler is excellent at catching errors that might slip through in other languages.

Move’s design in Sui focuses on preventing unintended asset manipulation. Its resource-oriented programming model enforces rules that safeguard assets, reducing common smart contract vulnerabilities.

Regardless of the platform, understanding platform-specific attack vectors and following security best practices is essential. Regular code reviews, audits, and thorough testing are non-negotiable in this space.

Final Thoughts

Optimizing gas costs is a complex challenge that depends on understanding the nuances of different blockchain architectures. Ethereum and Optimism require careful contract optimization and can benefit from Layer 2 solutions to mitigate high fees. Non-EVM blockchains like Solana and Sui offer alternative approaches with inherently lower fees and different optimization strategies.

Choosing the right platform involves considering technical requirements, development resources, long-term goals, and the target audience.

  • For some projects, Ethereum’s rich ecosystem and familiarity may outweigh the drawbacks of higher gas fees.
  • For others, the performance benefits and cost savings of Solana or Sui may be more compelling.

Regardless of the platform, understanding platform-specific attack vectors and following security best practices is essential. Regular code reviews, audits, and thorough testing are non-negotiable in this space.

Sources

1. Ethereum Gas and Fees

• Ethereum Documentation: ethereum.org/en/developers/docs/gas/

• ConsenSys Knowledge Base: consensys.net/knowledge-base/ethereum-gas/

2. Optimism Layer 2 Solution

• Optimism Official Website: optimism.io

• Optimism Documentation: community.optimism.io/docs/

3. Solana

• Solana Official Website: solana.com

• Solana Documentation: docs.solana.com

4. Sui and Move Language

• Sui Official Site: sui.io

• Move Language Documentation: move-language.github.io/move/

5. Gas Optimization Techniques

• Solidity Gas Optimization: soliditylang.org

• OpenZeppelin Guides: docs.openzeppelin.com/learn/gas-optimization

Placeholder

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.