Whitepaper - Ethereum Classic With Cover
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Ethereum</strong> <strong>Classic</strong> Documentation, Release 0.1<br />
Example transaction cost<br />
Let’s take a contract that just adds 2 numbers. The EVM OPCODE ADD consumes 3 gas.<br />
The approximate cost, using the default gas price (as of January 2016), would be:<br />
3 * 0.05e12 = 1.5e11 wei<br />
Since 1 Ether is 1e18 wei, the total cost would be 0.00000015 Ether.<br />
This is a simplification since it ignores some costs, such as the cost of passing the 2 numbers to contract, before<br />
they can even be added.<br />
• question<br />
• gas fees<br />
• gas cost calculator<br />
• <strong>Ethereum</strong> Gas Prices<br />
Operation Name Gas Cost Remark<br />
step 1 default amount per execution cycle<br />
stop 0 free<br />
suicide 0 free<br />
sha3 20<br />
sload 20 get from permanent storage<br />
sstore 100 put into permanent storage<br />
balance 20<br />
create 100 contract creation<br />
call 20 initiating a read-only call<br />
memory 1 every additional word when expanding memory<br />
txdata 5 every byte of data or code for a transaction<br />
transaction 500 base fee transaction<br />
contract creation 53000 changed in homestead from 21000<br />
Account interactions example - betting contract<br />
As previously mentioned, there are two types of accounts:<br />
• Externally owned account (EOAs): an account controlled by a private key, and if you own the private key<br />
associated with the EOA you have the ability to send ether and messages from it.<br />
• Contract: an account that has its own code, and is controlled by code.<br />
By default, the <strong>Ethereum</strong> execution environment is lifeless; nothing happens and the state of every account remains<br />
the same. However, any user can trigger an action by sending a transaction from an externally owned account,<br />
setting <strong>Ethereum</strong>’s wheels in motion. If the destination of the transaction is another EOA, then the transaction<br />
may transfer some ether but otherwise does nothing. However, if the destination is a contract, then the contract in<br />
turn activates, and automatically runs its code.<br />
The code has the ability to read/write to its own internal storage (a database mapping 32-byte keys to 32-byte<br />
values), read the storage of the received message, and send messages to other contracts, triggering their execution<br />
in turn. Once execution stops, and all sub-executions triggered by a message sent by a contract stop (this all<br />
happens in a deterministic and synchronous order, ie. a sub-call completes fully before the parent call goes any<br />
further), the execution environment halts once again, until woken by the next transaction.<br />
Contracts generally serve four purposes:<br />
• Maintain a data store representing something which is useful to either other contracts or to the outside world;<br />
one example of this is a contract that simulates a currency, and another is a contract that records membership<br />
in a particular organization.<br />
76 Chapter 1. Contents