A transaction is a message that is sent from one account to another account. It can include binary data (its payload) and Ether.
If the target account contains code, that code is executed and the payload is provided as input data.
In this exercise, reset()
or tick()
execution is a transaction.
Each transaction is charged with a certain amount of gas. EVM executes the transaction, gas is gradually depleted according to rules in yellowpaper.io (page 20).
Unused gas is immediately refunded.
Transaction fee in ETH is gas_price * gas
, gas_price
is set by the creator of the transaction.
Each contract has persistent state called storage (key-value store that maps 256-bit words to 256-bit words). It's relatively expensive to write to storage. Are you able find in yellowpaper.io how much it costs?
Calls are executed locally by Ethereum node and don't require verification through blockchain consensus. You can think about calls as read-only transactions. Calls are free to make.
In this exercise, count()
execution is a call.
A variable which is declared will have an initial default value whose byte-representation is all zeros:
bool // false
int // 0
uint // 0
bytes // []
Solidity inherits its scoping rules from JavaScript. Solidity inherits its scoping rules from JavaScript. It works like each variable is was declared with var keyword and is hoisted.
- ETH Gas Station - consumer oriented metrics for Ethereum gas
- Etherscan - the most important block explorer for Ethereum