0.0735 s - время 147 - запросов

We use cookies in order to improve your experience while using our website. If you continue to use our site, you accept our Cookies Policy, revised Privacy Policy and updated Terms of Use.

BTC $ 4026.40456231 (-1.41 %)
ETH $ 136.655324023 (-2.63 %)
XRP $ 0.3119521423 (-2.17 %)
LTC $ 59.2273322676 (-2.18 %)
EOS $ 3.6597754946 (-2.19 %)
BCH $ 154.324118183 (-3.87 %)
BNB $ 14.7304400315 (-4.14 %)
XLM $ 0.1074183785 (-3.86 %)
USDT $ 1.0097587003 (-0.15 %)
TRX $ 0.0225529247 (-1.71 %)

Gas For Smart Contracts In Ethereum

08:15 26/02/2019
Smart Contracts In Ethereum

Introduction

 

Ethereum is a complex system based on blockchain. It is intended to be flexible, efficient, secure, and decentralized. It’s main idea in being the “World Computer”. This implies that each participant is able to change the state of the whole Ethereum network. Each change is considered as a single solid step that is either executed or not.

 

Every step consists of two parts. The part one deals with asset transferring. Information about money that are to be sent is included in transactions of the next block. These transactions are protected with cryptographic algorithms, which makes them as much secure as possible. The part two is related to smart contract execution.

 

Smart contracts used in the Ethereum environment are small programs written in a special programming language. They are based on a solid fundament of Ethereum development solutions. Ethereum has its own complex and flexible virtual machine. It is used to support Application Binary Interface. This interface is the core element of smart contract processing regardless of what language smarts are written in.

 

Still, there is a problem that arises in the context of smart contract execution. We are talking about the code processing and capacity spent on this process.

 

Smart Contract Processing

 

Before we get deeper into the topic of smart contact execution, let’s recollect how these programs are created, processed, and stored. In order to place smart contracts on blockchain, participants should perform several steps.

 

First, they need the smart contract code itself. Second, they are to support the contract with a sufficient amount of ethers. Third, they should check the code for logic and accessibility. The main problem here is that smart contracts cannot carry out their functions without ether supply and a correct workflow.

 

Smart contract processing is rather simple. If you want to call a smart contact, you should create your own transaction. Commonly, contract authors explain the rules for transaction processing. One more way to call a smart contract is to create another contract that would perform this action. All contract codes are kept on blockchain until they get erased.

 

Gas For Contracts

 

So what is the main problem of contract processing from the point of view of performance? The answer is simple. Since contracts consist of commands and block processing requires these commands to be executed, it is fair to measure transaction fee. The simplest way to measure these efforts is to add another measurement unit. That’s what such a unit as gas was created for.

 

Gas is used to measure commands in the Ethereum environment. Complex commands require more gas, while simple commands cost less. Only two commands do not require gas whatsoever: clearing a contract and clearing a storage. This means that contracts that clear space are mostly preferable. Each gas unit has its cost in ether. This is how ether asset value is connected with the complexity of smart contract execution.

 

As a rule, before a contract is executed, a miner checks the amount of gas supplied by a transaction author. If it is not enough, nothing is going to happen. After the gas supply is calculated, it’s multiplied by the gas price. If the allocated amount of ethers is enough to cover the price of smart contract processing, then the contract is exacuted.

 

Afterword

 

Such an approach as the gas application in Ethereum is not unique. Let’s remember the NEO project and its own virtual machine. It operates in accordance with the similar rules.

 

As for gas, there are many important aspects that must be considered when working with it in the Ethereum network. This includes command optimization, exceeding the gas limit in a block, gas refund, and more. We will cover these issues in our next articles.

Found a mistake? Highlight it and press Ctrl + Enter to notify the administrator.

Up-to-date Blockchain and cryptocurrency news. Be the first to know!

What is it for?