Ethereum & Smart Contracts — Web3

Ethereum & Smart Contracts Ethereum bukan sekadar cryptocurrency — ini adalah programmable blockchain. Kamu bisa menulis kode (smart contract) yang berjalan…

Ethereum & Smart Contracts

Ethereum bukan sekadar cryptocurrency — ini adalah programmable blockchain. Kamu bisa menulis kode (smart contract) yang berjalan di atas blockchain, dieksekusi oleh ribuan node secara bersamaan.

Ethereum Virtual Machine (EVM)

EVM adalah "komputer global" yang menjalankan smart contract. Setiap node Ethereum menjalankan EVM yang sama, memastikan semua orang mendapat hasil yang sama (deterministic).

// Smart contract di-compile menjadi EVM bytecode
// Solidity → compile → bytecode → deploy ke blockchain
// Setiap node menjalankan bytecode yang sama

// Contoh flow:
// 1. Developer menulis Solidity
// 2. Compiler menghasilkan bytecode + ABI
// 3. Bytecode di-deploy ke address tertentu
// 4. Siapa pun bisa memanggil fungsi via ABI

Tipe Akun di Ethereum

AspekEOA (Externally Owned Account)Contract Account
Dikendalikan olehPrivate key (manusia)Kode (smart contract)
Bisa inisiasi transaksi?YaTidak (hanya merespon)
Punya kode?TidakYa (immutable)
ContohWallet MetaMask kamuUniswap Router contract

Gas: Biaya Komputasi

Setiap operasi di EVM membutuhkan gas. Gas mencegah infinite loops dan spam. Kamu membayar gas dalam ETH.

// Gas calculation:
// Total biaya = gas_used × gas_price

// Contoh (post EIP-1559):
// Base fee: 20 gwei
// Priority fee (tip): 2 gwei
// Gas used: 21000 (simple transfer)

// Total = 21000 × (20 + 2) gwei = 462000 gwei = 0.000462 ETH

// Gas limits per operasi:
// Simple ETH transfer: ~21,000 gas
// ERC-20 transfer: ~65,000 gas
// Uniswap swap: ~150,000 gas
// NFT mint: ~100,000 - 200,000 gas

Smart Contract = Kode yang Tidak Bisa Diubah

Setelah di-deploy, kode smart contract immutable (tidak bisa diubah). Inilah mengapa audit keamanan sangat penting sebelum deploy.

Testnet vs Mainnet

Yang akan kamu pelajari