Smart Contract Design in Times of Congested Networks

Updated on: August 12th, 2020
This content has been Fact-Checked.
Smart Contract Design in Times of Congested Networks

In this article, let’s understand what Ethereum gas means and why it has skyrocketed recently. After that, we will see how other smart contract platforms like RSK and EOS deal with gas prices when it comes to Smart Contract Design.

Ethereum has a gas problem. As funny as it may sound, we can assure you that developers are doing anything but laughing at that statement.

The growing demand for DeFi (decentralized finance) applications has increased congestion on the main Ethereum blockchain. This has, in turn, shot up the gas prices on the main chain. As per Bitinfocharts, the median transaction fees have shot up to its highest levels since early 2018.


Smart contract and Ethereum Virtual Machine (EVM)

Smart contracts are automated contracts. They are self-executing with specific instructions written on its code, which get executed when certain conditions are made.

You can learn more about smart contracts in our in-depth guide here.

Smart contracts are how things get done on the Ethereum ecosystem. When someone wants to get a particular task done in Ethereum they initiate a smart contract with one or more people.

Smart contracts are a series of instructions written using the programming language “solidity”, which works based on the IFTTT logic, aka the IF-THIS-THEN-THAT logic. Basically, if the first set of instructions is done, then execute the next function and after that the next and keep on repeating until you reach the end of the contract.

This is the core principle behind smart contracts. This is what allows us to have a binding agreement between multiple parties overseen by code, instead of a third-party, like a lawyer.

What is the Ethereum Virtual Machine?

Ethereum virtual machines are ecosystems wherein you execute smart contracts. Proper smart contract functionality requires three significant things:

  • Deterministic.
  • Terminable.
  • Isolated.

Feature #1: Deterministic

A program is deterministic if it gives the same output to a given input every single time. Eg. If 3+1 = 4 then 3+1 will ALWAYS be 4 (assuming the same base). So when a program gives the same output to the same set of inputs in different computers, it is called deterministic.

Feature #2: Terminable

In mathematical logic, we have an error called “halting problem.” Basically, it states that there is an inability to know whether or not a given program can execute its function in a time limit. This is obviously a problem with smart contracts because contracts, by definition, must be capable of termination in a given time limit. Smart contracts need an environment where they can integrate a halting mechanism.

Feature #3: Isolated

In a blockchain, anyone and everyone can upload a smart contract. However, because of this, the contracts may, knowingly and unknowingly, contain viruses and bugs. If the contract is not isolated, this may hamper the whole system. Hence, it is critical for a contract to be kept isolated in a sandbox to save the entire ecosystem from any adverse effects.

Ethereum provides all these functionalities through the EVM. It’s a simple yet powerful Turing Complete 256-bit virtual machine.

What is Ethereum Gas?

Gas is a unit that measures the amount of computational effort that it will take to execute certain operations. All the smart contracts that run in the EVM are coded using solidity (Ethereum is planning to move on to Viper from Solidity in the future.)  Each and every line of code in solidity requires a certain amount of gas to get computed.

The image below has been taken from the Ethereum Yellowpage and can be used to gain a rough idea of how much specific instructions cost gas-wise.

Image Courtesy: Ethereum Yellow Paper

To better understand how gas works in Ethereum, let’s use an analogy. Suppose you are going on a roadtrip. Before you do so you go through these steps:

  • You go to the gas station and specify how much gas you want to fill up in your car.
  • You get that gas filled up in your car.
  • You pay the gas station the amount of money you owe them for the gas.

Now, let’s draw parallels with Ethereum.

The car is the operation that you want to execute, like a gas or a smart contract.

The gas is well….gas.

The gas station is your miner.

The money that you paid them is the miner fees.

All the operations that users want to execute in ethereum must provide gas for the following:

  • To cover its data aka intrinsic gas.
  • To cover its entire computation.

Now that we have covered the bare basics, you maybe asking the following question.

Why do we have this Gas system?

The answer is simple…incentivization.

Like any proof-of-work peer-to-peer system, Ethereum is heavily dependent on the hashrate of their miners. More the miners, more the hashrate, more secure, and fast the system.

To attract more miners into the system they need to make the system as profitable and alluring as possible for the miners. In Ethereum, there are two ways that miners can earn money:

  • By mining blocks and getting block rewards.
  • By becoming temporary dictators of their mined blocks.

Let’s explore the second point.

The miners are responsible for putting transactions inside their blocks. To do so, they must use their computational power to validate smart contracts. The gas system allows them to charge a specific fee for doing so.

This fee is known as the miner’s fee and it helps incentivize them enough to take part actively in the ecosystem.

So, how much fees can they charge? Before we can calculate that let’s understand how we measure gas.

The smallest unit of gas measurement is wei. So, if we spend 1 gas unit during an operation, we call it 1 wei.

The units of measurements increase like this:

Image Credit: Steemit

Before we go any further, it is important to know the concept of Gas Limit.

What is Gas Limit?

To get an operation done in Ethereum, the operation generator (i.e. the person initiating the transaction or the smart contract creator) must specify a gas limit before submitting it to the miners. When a gas limit has been defined, only then will the miners start executing the operation.

When submitting a gas limit, the following points must be considered:

  • Different operations will have different gas costs (as has been shown before).
  • The miners will stop executing the moment the gas runs out.
  • If there is any gas left over, it will be immediately refunded to the operation generator.

Let’s see this in operation in a hypothetical scenario.

Suppose, we are adding two numbers and for that the contract must do the following actions:

  • Storing 10 in a variable. Let’s say this operation costs 45 wei gas.
  • Adding two variables, let’s say this costs 10 wei gas.
  • Storing the result which again costs 45 wei gas.

Suppose the gas limit is 120 wei.

The total gas used by the miner is (45+10+45) 100 wei.

The fees that is owed to them assuming 1 wei costs 0.02 micro ETH is (100*0.02 micro ETH) = 0.000002 ETH.

Now, how much gas is left over?

120 – 100 = 20 wei.

The 20 wei is refunded back to the operation generator.

So, having specified that, there are two scenarios that one must consider:

  • The Gas Limit is too low.
  • The Gas Limit is too high.

Scenario #1: The Gas Limit is too low

If an operation runs out of gas, then it is reverted back to its original state like nothing actually happened, however, the operation generator must STILL pay the miners the fee for their computational costs and the operation gets added to the blockchain (even if it has not been executed).

Going back to our road trip analogy, if you haven’t filled up enough gas in your car, then you will not be able to reach your destination, but even then you paid the gas station the money for the fuel right?

Let’s see how this works in our hypothetical addition smart contract. The step were:

  • Storing 10 in a variable. Let’s say this operation costs 45 wei gas.
  • Adding two variables, let’s say this costs 10 wei gas.
  • Storing the result which again costs 45 wei gas.

However, this time, the gas limit is 90 wei.

Now, we know that the gas that will be required for fulfilling the contract is 100 wei, but we only have 90 wel limit.

In this scenario, the miner will do 90 wei worth of computation and then charge the operation generator fees for the 90 wei which turns out to be (90 * 0.02 micro ETH) 0.000018 ETH.

Also, the contract reverts back to its original state and is added to the blockchain.

Scenario #2: The Gas Limit is too high

So, what if we set the gas limit too high?

That would make sense to do right? After all whatever is leftover gets refunded to the operation generator right?

That sounds good on paper but it doesn’t really work that well in reality. You have to remember that each block on Ethereum has an overall gas limit. Miners can only add operations which add up to be less than or equal to the block gas limit.

Image courtesy: Hackernoon

Suppose there is a transaction A which has a gas limit of 42,000 and two transactions B and C which have normal limits of 21,000.

Which will make more sense for a miner to put in their block?

  • Will they put in transaction A and refund back a huge amount of gas?
  • Or will they put transactions B and C and refund little to nothing back?

The second point makes more sense to them economically right?

This is precisely why having a bloated gas limit is not the sensible way to go.

High and Low Gas vs High and Low Fee

It should be clear to you so far that gas and ether are not the same thing. Gas is the amount of computational power required while ether is the price aka the FEES that one must pay for that gas.

Now with the knowledge of everything we have obtained so far, let’s go through certain gas and fees scenarios.

  • If an operation has LOW gas, then the miners won’t even pick it up because it doesn’t have enough gas to finish computation.
  • If an operation has LOW fees, then it might have just enough gas to cover it but still the miners won’t be chomping at the bits to pick it up because an operation with low fees isn’t economically viable for them.
  • If an operation has HIGH gas, then it means that the operation is bloated with a high gas limit and hence the miners will not pick it up.
  • If an operation has HIGH fees, then the miners know that they will make a lot of money and pick it up instantly.

The recommended gas prices for different transaction fees, according to ethgasstation are:

Rising Ethereum Gas Prices

The Ethereum blockchain has seen increased usage in recent times. This is because of the increase in the usage of more complicated smart contracts.

As per Ethereum gas station, stablecoins like USDT and decentralized exchanges like Uniswap are the more gas hungry smart contracts in the space. This increased usage prompts users to pay higher fees to get their transactions processed faster. As such, when there’s lots of activity, the fee rates can quickly spiral upward.

To understand how drastic the situation is, consider this. According to Coin Metrics, at one point,  the average cost per transaction has climbed to a 7-day average of about 91 cents, from about 8 cents at the start of 2020.  Digital Assets Data’s Connor Abendschein notes:

“As of now, high gas fees are keeping smaller players from being able to participate in some of DeFi’s most interesting protocols, such as Synthetix.”

This is an absolute shame because Ethereum and DeFi is to build an open and easily accessible global financial system.

The worse part is that this problem is only going to worsen as more complicated DeFi protocols and users enter the ecosystem.

So, how are Ethereum’s competitors dealing with the gas problem? Let’s take a look..

Smart Contract Design in EOS: Ownership Model

The Ethereum gas system can be thought of as a rental model. Ethereum is a global supercomputer, wherein you rent resources (gas) to create and run your application.

EOS, on the other hand, uses an ownership model. Instead of being a decentralized supercomputer, EOS plans to become a decentralized operating system that Dapp developers can utilize to create and code various Dapps. The EOS tokens act as a toll booth, and holding them gives you access to various resources such as Bandwidth, Computation, and RAM.

Since these resources are scarce, EOS doesn’t want you to hold on to their tokens for too long. The company behind EOS,, has explicitly mentioned in the platform constitution that EOS members who don’t use their tokens for three years would get their account terminated.

By staking and locking up EOS tokens, you are provided an equivalent amount of resources in network and CPU bandwidth in return. However, since RAM is a scarce resource, you don’t get it automatically by staking. So, to obtain them, you will need to purchase it directly from the RAM marketplace.

Each time someone buys or sells RAM, a 0.5% fee is applied to both the buyer’s side and the seller’s side (1% overall). This actually gives users an economic incentive to sell their RAM and discourages speculative marketing and inflation as the collected fees are promptly burned (removed from the ecosystem).

This internal RAM marketplace will make sure that there is a steady availability of RAM and will offset any future predicted shortages. You will be able to buy RAM based on the price that the system sets it on, based on the currently available RAM supply.

By buying and using these resources, developers are then able to create decentralized applications.

EOS Development Costs

As opposed to Ethereum, you don’t need to pay gas prices in EOS. You need to stake your EOS tokens to receive Bandwidth, CPU, and storage for your smart contract. Along with all this, you will still need RAM. Since RAM is such a rare resource, you need to buy it from an internal RAM marketplace. According to EOS resource planner, RAM costs $0.154 USD per KiB

So, with all that information in mind, let’s see how much EOS you will have to stake to run an application. Let’s assume that we are going to make an application for 1000 users. You will need to consider the following metrics:

  • Pay for each user account.
  • You will need to pay for their storage
  • You will also need to account for the network bandwidth and CPU bandwidth that you will need as well.

RSK – The Bridge between Bitcoin and Ethereum – Smart Contract Design

Rootstock (RSK) is a smart contract platform that is connected to the Bitcoin blockchain through sidechain technology. Rootstock was born to be compatible with Ethereum’s applications (the web3/EVM/Solidity model) and bitcoin as the underlying cryptocurrency. The idea behind the creation of RSK was to give the Bitcoin blockchain smart contract functionalities. At its very core, Rootstock is a combination of:

  • A Turing-complete resource-accounted deterministic virtual machine (for smart contracts) compatible with Ethereum’s EVM.
  • A two-way pegged Bitcoin sidechain (for BTC denominated trade) based on a strong federation
  • A SHA256D merge-mining consensus protocol (for consensus security relying on Bitcoin’s miners) with 30-seconds block interval. (for fast payments).

RSK allows you to build token bridges that connect directly to the Ethereum blockchain. This allows the contract creator to leverage the advantages of both the blockchains, but it also allows for the creation of a thriving, interoperable ecosystem between the two.

So, how does this translate to gas prices? RSK has historically been cheaper than Ethereum when it comes to gas costs.

The blue line above is Ethereum’s gas price, while the green line down way below is RSK’s gas price. If you need more clarification as to how much more gas efficient RSK is when compared to Ethereum, then check this out:

Here is the avg. transaction fees comparison of Ethereum and RSK over the last ten days. So, what this means is that not only is RSK cheaper, but it also brings in the overall security of the Bitcoin blockchain, giving it a distinct advantage over both Ethereum and EOS.


As we enter a whole new era of DeFi innovation and broader adoption, developers will need a platform where they can efficiently develop their applications. While no one denies that Ethereum is a first-mover, other platforms like RSK have definitely made strong cases as potential heavy hitters of the future. If we take into consideration the fact that developing smart contracts and all kind of fungible tokens and non-fungible tokens is a seamless process on RSK, developers have great incentives to test this smart contract platform.


Rajarshi Mitra
Rajarshi started writing in the blockchain space after listening to Andreas Antonopoulos’ podcast with Joe Rogan. A content generating machine, Rajarshi has been consistently producing high-quality guides and articles for us since late 2016. His articles have been shared extensively in social media and several start-ups have used his guide as learning material for their staff. He is continuously invited all over his country to give talks in various crypto seminars and conferences. He has gained a solid reputation as a speaker/educator on top of being one of the most promising writers in the crypto space. When he is not busy nerding out over the latest in the blockchain/crypto space, he is usually busy watching re-runs of top gear and MMA.

Like what you read? Give us one like or share it to your friends and get +16

Hungry for knowledge?
New guides and courses each week
Looking to invest?
Market data, analysis, and reports
Just curious?
A community of blockchain experts to help

Get started today

Already have an account? Sign In