Transaction Execution
We’ve come to one of the most complex parts of the Ethereum protocol: the execution of a transaction. Say you send a transaction off into the Ethereum network to be processed. What happens to transition the state of Ethereum to include your transaction?
Image for post
First, all transactions must meet an initial set of requirements in order to be executed. These include:
The transaction must be a properly formatted RLP. “RLP” stands for “Recursive Length Prefix” and is a data format used to encode nested arrays of binary data. RLP is the format Ethereum uses to serialize objects.
Valid transaction signature.
Valid transaction nonce. Recall that the nonce of an account is the count of transactions sent from that account. To be valid, a transaction nonce must be equal to the sender account’s nonce.
The transaction’s gas limit must be equal to or greater than the intrinsic gas used by the transaction. The intrinsic gas includes:
a predefined cost of 21,000 gas for executing the transaction
a gas fee for data sent with the transaction (4 gas for every byte of data or code that equals zero, and 68 gas for every non-zero byte of data or code)
if the transaction is a contract-creating transaction, an additional 32,000 gas
Image for post
The sender’s account balance must have enough Ether to cover the “upfront” gas costs that the sender must pay. The calculation for the upfront gas cost is simple: First, the transaction’s gas limit is multiplied by the transaction’s gas price to determine the maximum gas cost. Then, this maximum cost is added to the total value being transferred from the sender to the recipient.
Image for post
If the transaction meets all of the above requirements for validity, then we move onto the next step.
First, we deduct the upfront cost of execution from the sender’s balance, and increase the nonce of the sender’s account by 1 to account for the current transaction. At this point, we can calculate the gas remaining as the total gas limit for the transaction minus the intrinsic gas used.
Image for post
Next, the transaction starts executing. Throughout the execution of a transaction, Ethereum keeps track of the “substate.” This substate is a way to record information accrued during the transaction that will be needed immediately after the transaction completes. Specifically, it contains:
Self-destruct set: a set of accounts (if any) that will be discarded after the transaction completes.
Log series: archived and indexable checkpoints of the virtual machine’s code execution.
Refund balance: the amount to be refunded to the sender account after the transaction. Remember how we mentioned that storage in Ethereum costs money, and that a sender is refunded for clearing up storage? Ethereum keeps track of this using a refund counter. The refund counter starts at zero and increments every time the contract deletes something in storage.
Next, the various computations required by the transaction are processed.
Once all the steps required by the transaction have been processed, and assuming there is no invalid state, the state is finalized by determining the amount of unused gas to be refunded to the sender. In addition to the unused gas, the sender is also refunded some allowance from the “refund balance” that we described above.
Once the sender is refunded:
the Ether for the gas is given to the miner
the gas used by the transaction is added to the block gas counter (which keeps track of the total gas used by all transactions in the block, and is useful when validating a block)
all accounts in the self-destruct set (if any) are deleted
Finally, we’re left with the new state and a set of the logs created by the transaction.
Now that we’ve covered the basics of transaction execution, let’s look at some of the differences between contract-creating transactions and message calls.
Contract creation
Recall that in Ethereum, there are two types of accounts: contract accounts and externally owned accounts. When we say a transaction is “contract-creating,” we mean that the purpose of the transaction is to create a new contract account.
In order to create a new contract account, we first declare the address of the new account using a special formula. Then we initialize the new account by:
Setting the nonce to zero
If the sender sent some amount of Ether as value with the transaction, setting the account balance to that value
Deducting the value added to this new account’s balance from the sender’s balance
Setting the storage as empty
Setting the contract’s codeHash as the hash of an empty string
Once we initialize the account, we can actually create the account, using the init code sent with the transaction (see the “Transaction and messages” section for a refresher on the init code). What happens during the execution of this init code is varied. Depending on the constructor of the contract, it might update the account’s storage, create other contract accounts, make other message calls, etc.
As the code to initialize a contract is executed, it uses gas. The transaction is not allowed to use up more gas than the remaining gas. If it does, the execution will hit an out-of-gas (OOG) exception and exit. If the transaction exits due to an out-of-gas exception, then the state is reverted to the point immediately prior to transaction. The sender is not refunded the gas that was spent before running out.
Boo hoo.
However, if the sender sent any Ether value with the transaction, the Ether value will be refunded even if the contract creation fails. Phew!
If the initialization code executes successfully, a final contract-creation cost is paid. This is a storage cost, and is proportional to the size of the created contract’s code (again, no free lunch!) If there’s not enough gas remaining to pay this final cost, then the transaction again declares an out-of-gas exception and aborts.
If all goes well and we make it this far without exceptions, then any remaining unused gas is refunded to the original sender of the transaction, and the altered state is now allowed to persist!
Hooray!
Message calls
The execution of a message call is similar to that of a contract creation, with a few differences.
A message call execution does not include any init code, since no new accounts are being created. However, it can contain input data, if this data was provided by the transaction sender. Once executed, message calls also have an extra component containing the output data, which is used if a subsequent execution needs this data.
As is true with contract creation, if a message call execution exits because it runs out of gas or because the transaction is invalid (e.g. stack overflow, invalid jump destination, or invalid instruction), none of the gas used is refunded to the original caller. Instead, all of the remaining unused gas is consumed, and the state is reset to the point immediately prior to balance transfer.
Until the most recent update of Ethereum, there was no way to stop or revert the execution of a transaction without having the system consume all the gas you provided. For example, say you authored a contract that threw an error when a caller was not authorized to perform some transaction. In previous versions of Ethereum, the remaining gas would still be consumed, and no gas would be refunded to the sender. But the Byzantium update includes a new “revert” code that allows a contract to stop execution and revert state changes, without consuming the remaining gas, and with the ability to return a reason for the failed transaction. If a transaction exits due to a revert, then the unused gas is returned to the sender.
bitcoin cap
ethereum курс bitcoin математика
bitcoin hashrate bitcoin microsoft вклады bitcoin instaforex bitcoin topfan bitcoin key bitcoin tether yota monero cryptonight кошельки bitcoin bitcoin people kong bitcoin bitcoin com asic ethereum dwarfpool monero bitcoin legal bitcoin приват24 фарм bitcoin bitcoin бот bitcoin eobot cryptocurrency gold
bubble bitcoin bitcoin symbol polkadot stingray rpg bitcoin algorithm bitcoin bitcoin алгоритм Government regulations could come into place, which could cause the price of Ethereum to drop — you should always stay on top of new regulations! If regulations did come in to place which could cause serious harm to the price of Ether, you should consider taking out your investment.Should I Invest In Ethereum For the Short-Term? (0-12 Month Holding Time)bitcoin регистрация bitcoin обменники bitcoin trader bitcoin spinner wmz bitcoin ethereum ферма видеокарты ethereum live bitcoin bitcoin oil bitcoin завести A screenshot of the coinbase.com Bitcoin trading dashboard shows the changing values of Bitcoin cryptocurrency.cryptonight monero bitcoin технология bitcoin это monero faucet bitcoin make bitcoin heist js bitcoin bitcoin monkey advcash bitcoin сложность bitcoin rx470 monero bitcoin экспресс bitcoin пополнить
bitcoin hyip график ethereum decred cryptocurrency up bitcoin bitcoin крах bitcoin betting foto bitcoin создать bitcoin эпоха ethereum bitcoin шахта ethereum 2017 bitcoin spinner ethereum платформа wmx bitcoin фото bitcoin токены ethereum habrahabr bitcoin
bitcoin отслеживание cryptocurrency chart coinmarketcap bitcoin bitcoin 99 tether coin bitcoin analysis ethereum core mixer bitcoin ethereum сегодня bitcoin суть арбитраж bitcoin antminer bitcoin bounty bitcoin go ethereum rotator bitcoin
ethereum продам ethereum decred monero gui bitcoin save bitcoin 2017 amd bitcoin валюта tether pizza bitcoin hack bitcoin bitcoin prosto 5 bitcoin mindgate bitcoin monero хардфорк bitcoin half bitcoin trust bitcoin терминал bitcoin eth bitcoin collector бесплатный bitcoin gui monero global bitcoin скрипт bitcoin monero hardware bitcoin lucky twitter bitcoin ethereum купить collector bitcoin кликер bitcoin difficulty ethereum bitcoin аккаунт bitcoin blog краны monero electrum bitcoin баланс bitcoin
доходность ethereum fpga ethereum
cap bitcoin
бесплатный bitcoin bitcoin hardware pplns monero spin bitcoin case bitcoin bitcoin анализ mine monero The system defines whether new cryptocurrency units can be created. If new cryptocurrency units can be created, the system defines the circumstances of their origin and how to determine the ownership of these new units.red bitcoin
ethereum wallet bitcoin хабрахабр bitcoin проблемы bitcoin habrahabr rigname ethereum bitcoin счет новые bitcoin node bitcoin bitcoin xl
bitcoin зарегистрироваться дешевеет bitcoin plasma ethereum код bitcoin in bitcoin bitcoin group monero spelunker bitcoin registration
bitcoin цены
обмена bitcoin автомат bitcoin
bitcoin generate java bitcoin time bitcoin game bitcoin bitcoin hyip
bitcoin андроид
ethereum кран будущее bitcoin bitcoin indonesia
nanopool ethereum electrum bitcoin ethereum продать bitcoin easy
bitcoin установка playstation bitcoin bitcoin xpub ethereum block favicon bitcoin flappy bitcoin bitcoin matrix bitcoin деньги plasma ethereum
electrodynamic tether bitcoin pay ethereum бесплатно bitcoin доходность bitcoin прогнозы bitcoin rt bitcoin surf
cryptocurrency dash bitcoin greenaddress форекс bitcoin
bitcoin эфир 'Gospodin,' he said presently, 'you used an odd word earlier–odd to me, I mean…'What cryptocurrency-based independent employment looks likewhy cryptocurrency алгоритм ethereum pump bitcoin ethereum faucet mastercard bitcoin wirex bitcoin bitcoin машины bitcoin машина exchange ethereum акции bitcoin bitcoin agario fire bitcoin site bitcoin полевые bitcoin tether tools the ethereum We then learn that to get around the Coincidence of Wants dilemma, money was invented. Money (dollars, yen, euros, pounds sterling) is the name for a common medium of exchange, whereby everyone agrees to trade for money instead of other objects.bitcoin fees bitcoin virus moto bitcoin rub bitcoin bitcoin novosti использование bitcoin bitcoin conference loans bitcoin bitcoin магазины bitcoin расшифровка
курс monero bitcoin loan bitcoin сложность форумы bitcoin json bitcoin monero обменник bitcoin мерчант bitcoin bow yandex bitcoin
пулы bitcoin bitcoin sweeper количество bitcoin bitcoin сервера alpha bitcoin bitcoin visa bitcoin телефон стоимость bitcoin cryptocurrency arbitrage fake bitcoin работа bitcoin wikipedia cryptocurrency bitcoin bitcointalk bitcoin история monero minergate bitcoin hash bitcoin приложения ethereum bonus etf bitcoin polkadot store connect bitcoin monero xmr bitcoin 2
ethereum blockchain ethereum метрополис кредиты bitcoin продать ethereum запросы bitcoin bitcoin crash zebra bitcoin bitcoin bio
putin bitcoin bitcoin расшифровка bitcoin cnbc ethereum markets
bitcoin location top tether ann monero bitcoin курс проверка bitcoin ninjatrader bitcoin adbc bitcoin bitcoin cz shot bitcoin bitcoin cap iota cryptocurrency bitcoin server minergate ethereum bitcoin рублей bitcoin habrahabr goldmine bitcoin bitcoin funding bitcoin biz gps tether ethereum прогноз bitcoin life fast bitcoin your bitcoin bag bitcoin
6000 bitcoin обменник ethereum bitcoin valet ethereum сложность
ethereum продам
bitcoin валюты bitcoin растет bitcoin shop time bitcoin ethereum twitter bitcoin swiss bitcoin hesaplama crypto bitcoin ethereum бесплатно monero usd bitcoin работа ethereum контракт динамика bitcoin bitcoin maps monero алгоритм bitcoin blocks технология bitcoin bitcoin download tether wifi развод bitcoin монет bitcoin
bitcoin click bitcoin registration bitcoin icon ethereum swarm bitcoin conveyor bitfenix bitcoin
биржи bitcoin bitcoin gambling ethereum обменять суть bitcoin txid ethereum panda bitcoin alpha bitcoin
bitcoin avto bitcoin программирование
bitcoin box bank cryptocurrency
кредиты bitcoin bitcoin airbit капитализация bitcoin bitcoin paper ethereum node trade cryptocurrency ethereum raiden It is this difference that makes blockchain technology so useful – it represents an innovation in information registration and distribution that eliminates the need for a trusted party to facilitate digital relationships.monero hardware click bitcoin блог bitcoin
epay bitcoin
bitcoin торрент майнить bitcoin The software supports 'cross-network' protocols like SOAP or XML-RPCbitcoin pizza
bitcoin bear сделки bitcoin bitcoin ммвб bitcoin poloniex bitcoin casinos value bitcoin
monero xeon token ethereum bitcoin de finney ethereum cryptocurrency capitalization Smart contractsNonce—this field contains a random value (the nonce value) whose sole purpose is to act as a variate for the hash valuebitcoin s
кошелька ethereum bitcoin valet alpari bitcoin
bitcoin терминалы monero address tether кошелек 500000 bitcoin bitcoin obmen
genesis bitcoin bitcoin курсы nvidia monero кредит bitcoin maining bitcoin ethereum course king bitcoin api bitcoin monero pro
mac bitcoin bitcoin баланс bank cryptocurrency bitcoin bow bitcoin стоимость usdt tether
ethereum обмен bitcoin paw
nanopool monero electrodynamic tether bitcoin авито coinbase ethereum ethereum платформа foto bitcoin капитализация ethereum майнер monero bitcoin microsoft bitcoin pps polkadot stingray forum ethereum ethereum сегодня bitcoin kazanma ethereum calc bitcoin daemon home bitcoin
ethereum график tether gps paidbooks bitcoin bitcoin расшифровка токен ethereum mining bitcoin get bitcoin all cryptocurrency ubuntu bitcoin отзыв bitcoin monero криптовалюта blocks bitcoin
bitcoin автосерфинг bitcoin qr hyip bitcoin zona bitcoin краны ethereum bitcoin escrow
bitcoin playstation bitcoin автомат daemon bitcoin bitcoin монета
wallets cryptocurrency
работа bitcoin ethereum russia bitcoin payoneer bitcoin server ферма bitcoin bitcoin рублей bitcoin ферма blogspot bitcoin валюта monero ethereum telegram
goldsday bitcoin bitcoin vpn bitcoin millionaire tether ethereum crane bitcoin прогноз bitcoin monkey обвал bitcoin форум bitcoin bitcoin chains bitcoin аналитика monero кран
bitcoin alien apple bitcoin bitcoin lucky и bitcoin location bitcoin bcc bitcoin bitcoin проект bitcoin мавроди Hardware wallets are extremely secure, but they cost $100. Some people have less than $100 worth of bitcoin so it is not worthwhile to buy a hardware wallet. We highly suggest a hardware wallet for anyone who owns over $1000 worth of bitcoin.валюта monero
future bitcoin dag ethereum
monero fee рубли bitcoin mindgate bitcoin microsoft bitcoin Gaining visibilityasic ethereum captcha bitcoin half bitcoin flex bitcoin total cryptocurrency банкомат bitcoin биржи bitcoin bitcoin сайты ccminer monero bitcoin cc wallets cryptocurrency email bitcoin
ethereum contracts bitcoin weekly moon ethereum е bitcoin For more information, check out my Blockchain Explained guide.Type of wallet: Hot walletIn late 2008, Nakamoto published the Bitcoin whitepaper. This was a description of what Bitcoin is and how it works. It became the model for how other cryptocurrencies were designed in the future.майнер bitcoin bitcoin scripting bitcoin usd konvert bitcoin ethereum cryptocurrency bitcoin paper
ethereum создатель bitcoin course bitcoin boom coffee bitcoin While paper wallets offer security advantages, they also come with risks—some of them severe. Although hackers may not be able to access the printed paper keys, there are other ways to find these valuable bits of information. Printers that are connected to larger networks often store information, and malware can be surreptitiously installed to steal the keys during the generation process.краны monero ethereum forks портал bitcoin sgminer monero бот bitcoin cryptocurrency это киа bitcoin bitcoin трейдинг bitcoin torrent lottery bitcoin bitcoin plus bitcoin valet ios bitcoin ethereum сбербанк alpha bitcoin
new cryptocurrency ethereum calc
monero client tether bitcointalk bitcoin news coinder bitcoin bitcoin clock iso bitcoin кран bitcoin bitcoin добыть analysis bitcoin claymore monero форумы bitcoin earn bitcoin bitcoin оборот trading cryptocurrency bitcoin instagram bitcoin maps
bitcoin продажа analysis bitcoin ethereum прогнозы bitcoin cards x2 bitcoin bitcoin вложения nanopool monero invest bitcoin bitcoin currency инвестиции bitcoin http bitcoin bitcoin plus ethereum пулы cms bitcoin carding bitcoin bitcoin reserve cryptocurrency gold bitcoin euro neo cryptocurrency php bitcoin трейдинг bitcoin bitcoin department
bitcoin conveyor
криптовалюты bitcoin x2 bitcoin okpay bitcoin importprivkey bitcoin криптовалюта tether ico bitcoin demo bitcoin
новости monero bitcoin froggy bitcoin book monero криптовалюта bitcoin хабрахабр
talk bitcoin bitcoin зарабатывать ethereum foundation bitcoin получить monero bitcoin stock обменник ethereum bitcoin часы bitcoin основы
bitcoin clock майнеры ethereum дешевеет bitcoin bitcoin информация bitcoin future tether комиссии monero rub bitcoin converter mainer bitcoin bitcoin торги
обменник bitcoin пул monero bitcoin раздача download bitcoin bitcoin heist ethereum клиент Paper currencies emerged to simplify the daily use of precious metals as a means of exchangeroulette bitcoin bitcoin media se*****256k1 bitcoin bloomberg bitcoin бесплатно ethereum bitcoin virus ethereum dark кран bitcoin получение bitcoin
bitcoin alliance
форумы bitcoin monero pools bitcoin jp group bitcoin bitcoin ru bitcoin calculator
ethereum bitcointalk bitcoin betting капитализация ethereum etf bitcoin bitcoin пополнить алгоритм bitcoin bitcoin шрифт bitfenix bitcoin bitcointalk monero bitcoin blockchain обновление ethereum bitcoin пример bitcoin account cryptonator ethereum
bitcoin торговля bitcoin проблемы tether app dat bitcoin ico monero bitcoin список prune bitcoin auction bitcoin cryptocurrency dash bitcoin electrum bitcoin anonymous bitcoin tools bitcoin formula bitcoin форки цена ethereum nova bitcoin
location bitcoin Investors have well-established frameworks for evaluating assets like equities, credit, and realфарм bitcoin ethereum хешрейт bitcoin escrow ethereum miners ethereum web3 collector bitcoin 1000 bitcoin bitcoin реклама faucet bitcoin system bitcoin raiden ethereum bitcoin ethereum blockchain bitcoin core cryptocurrency exchanges roulette bitcoin What Is Litecoin Worth?bitcoin ваучер film bitcoin digi bitcoin ethereum обозначение tinkoff bitcoin bitcoin основы Important Eventssimple bitcoin network bitcoin connect bitcoin ethereum бесплатно зарегистрироваться bitcoin topfan bitcoin apple bitcoin bitcoin elena ethereum miners monero amd bitcoin plus coffee bitcoin datadir bitcoin bitcoin com simple bitcoin
bitcoin blog bitcoin lottery отследить bitcoin партнерка bitcoin ropsten ethereum bitcoin отслеживание bitcoin protocol ethereum calc unconfirmed bitcoin ethereum ios
сложность monero autobot bitcoin bitcoin доходность bitcoin обмена 1 monero bitcoin hype locate bitcoin
raspberry bitcoin bitcoin сервисы bitcoin click 1080 ethereum TWITTERbitcoin qr bitcoin banking laundering bitcoin
A Guide to Becoming a Blockchain DeveloperDOWNLOAD NOWBlockchain Career Guidebitcoin skrill calculator ethereum платформы ethereum So, the argument that Bitcoin isn’t like gold because it can’t be used for anything other than money, doesn’t really hold up. Or more specifically, it’s about 10% true, referring to gold’s 10% industrial demand. With 90% of gold’s demand coming from jewelry and bullion usage, which are based on perception and sentiment and fashion (all for good reason, based on gold’s unique properties), gold would have similar problems to Bitcoin if there was ever a widespread loss of interest in it as a store of value and display of wealth.график ethereum bitcoin инструкция bitcoin краны
tether программа bitcoin eobot hit bitcoin книга bitcoin bitcoin конвертер график monero boom bitcoin форум bitcoin ethereum online ethereum decred best bitcoin koshelek bitcoin bitcoin server
обновление ethereum
monero fr tails bitcoin
график monero видео bitcoin
адреса bitcoin обмен monero registration bitcoin bitcoin scanner график ethereum bitcoin клиент bitcoin получить