by contract code Can create transaction Can create transaction in reponses incoming transaction Has a balance Has a balance and its own persistent state. (can call other contracts) Note: Contract (smart contract) is written by programing language like Vyper or Solidity
EOA, used to prevent message replay Gas price The price of gas (in wei) the originator is willing to pay Gas limit The maximum amount of gas the originator is willing to buy Recipient The destination Ethereum address (EOA or Contract Address) Value The amount of ether to send to the destination Data The variable-length binary data payload v, r, s The three components of an ECDSA digital signature of the originating EOA (we can know who send transaction from v, r, s)
number of transactions sent by the sender - The nonce isn’t stored as apart of an account’s state on the blockchain (it’s calculated dynamically) Why ? - Prevents double-spending How ? - Transaction must be in Order: transaction with nonce 2 can’t be mined before nonce of 1 - No Skipping
2. Ethereum is a Turning machine - a machine that can simulate any computer algorithm. If there were no fee (gas), a malicious actor could easily try to disrupt the network by executing an infinite loop within a transaction
record a state change, adding the value you sent to the balance of the address. 2. Contract Account: EVM (Ethereum Virtual Machine) will execute the contract and will attempt to call the function named in the data payload of your transaction. Transaction with Value = Payment
ignore any data received in a transaction to an EOA they control. 2. Contract Account: The data will be interpreted by the EVM as a contract invocation : a hex-serialized encoding of : - A function selector : First 4 bytes of the Keccak-256 hash of the function’s prototype - The function arguments: Hex of arguments Transaction with data, will almost come to Contract Account
chain ID and the recovery identifier to help the ECDSA recover function check the signature. - Sig = F sig ( Fkeccak256 ( m ) , k ) • k is the signing private key. • m is the RLP-encoded transaction. • Fkeccak256 is the Keccak-256 hash function. • Fsig is the signing algorithm. • Sig is the resulting signature. - Sig = (r, s)
transaction structure 2. Compute the Keccak-256 hash of serialized message 3. Compute the ECDSA signature: signing the hash with EOA private key 4. Append the ECDSA signature’s computed v, r, s to the transaction Transaction (nonce, gas price, gas limit, data, value, v, r=0, s=0) Serialized message (hex string) Transaction hash Signed raw transaction (1) (2) (3, 4)
gas • Predefined gas fee: Executing transaction (default) • Storage fee: Gas fee for data sent with the transaction • + 32k gas if transaction is a contract creation transaction
transaction pool 2. Miner node accepts transaction (transaction is included in block ) 3. Miner node find a valid block and broadcasts to the network 4. When block is added in blockchain, your tx will be locked into blockchain
3. How does Ethereum works, anyway ? 4. What is gas ? 5. What is gas - Ethereum StackExchange 6. Normal transaction - Internal Transaction 7. What does v, r, s mean ? 8. What is Nonce ? 9. Transactions in Ethereum