Study notesWeek 5: Ethereum And Smart Contracts
Week 5

Ethereum And Smart Contracts

Outcomes

What You Will Be Able To Do

Idea

Why Ethereum

Idea with limits

The World Computer, Honestly

Accounts

World State: A Table Of Accounts

AccountControlled by
Externally ownedA private key
ContractIts own code
0xAb...12  balance 1.5 ETH  nonce 7  (EOA)
0xCd...34  balance 0.0 ETH  nonce 1  code, storage (contract)
EOA and contract

Two Kinds Of Account

Fields

Anatomy Of A Transaction

to:        0xRecipient
value:     0.001 ETH
data:      0x (empty)
gasLimit:  21000
nonce:     7
signature: (r, s, v)
Definition

What Is A Smart Contract?

Execution

The EVM

Fees

Gas: Paying For Computation

EIP-1559

Fee = Gas Used X (Base Fee + Tip)

gas_used = 21_000
price    = 20            # gwei, base fee + tip
fee_gwei = gas_used * price
fee_eth  = fee_gwei / 1e9
print(fee_eth)           # 0.00042
Units and practice

Ether, Wei And Testnets

UnitWei
wei1
gwei10^9
ether10^18
Hands-on

Live: Your First Testnet Transaction

Block explorer

Reading A Transaction Page

Python

Reading The Chain With Web3.Py

from web3 import Web3

URL = 'https://ethereum-sepolia-rpc.publicnode.com'
w3 = Web3(Web3.HTTPProvider(URL))
print(w3.is_connected())
print(w3.eth.block_number)
block = w3.eth.get_block('latest')
print(block['baseFeePerGas'])
bal = w3.eth.get_balance('0xYourAddress')
print(Web3.from_wei(bal, 'ether'))
Week 5 in five lines

Recap

Week 6

Next Week: Your First Contract

Hands-on

Questions And Exercise