BLOCKCHAIN · ETHEREUM · GO · 20 LESSONS
Blockchain infrastructure in Go
Build the primitives yourself first, then operate real protocol libraries safely. The examples use go-ethereum v1.17 with fixed test keys and in-memory models: nothing here creates a wallet, connects to a node or signs a real transaction.
Start with “Hash chains: every block commits to the exact bytes of the block before it” →
Who it is for
Backend engineers who integrate with Ethereum or other chains, build indexers and wallets-adjacent services, or need to reason about finality and money-safe arithmetic.
Before you start
Basic Go: slices, structs, errors and byte handling; no prior blockchain experience.
What you will be able to do
- Verify hash chains and Merkle inclusion proofs, and explain why canonical encoding matters.
- Sign and recover with secp256k1, validate EIP-55 addresses and encode with RLP.
- Bound Ethereum JSON-RPC calls, pin reads to a block and compare providers.
- Compute EIP-1559 fees exactly, build and decode raw transactions, and index events through reorgs.
Unit 1. Blockchain foundations in Go
Hash chains, Merkle proofs, signatures, addresses, account and UTXO ledgers, RLP, proof of work and fork choice.
Hash chains: every block commits to the exact bytes of the block before it
Link blocks with SHA-256 over a canonical byte encoding, verify the chain from genesis and report the first link that breaks.
5 min · Worked lesson
Merkle proofs: show one transaction is in a block with about log2(n) hashes
Build a domain-separated Merkle tree, generate and verify inclusion proofs, and explain the duplicate-leaf and second-preimage pitfalls.
5 min · Worked lesson
secp256k1 signatures: sign a 32-byte digest, recover the signer and reject high-s twins
Sign a Keccak-256 digest with go-ethereum's crypto package, recover and check the signer's address, and enforce the low-s rule on untrusted signatures.
5 min · Worked lesson
Ethereum addresses: 20 bytes of Keccak-256, an EIP-55 checksum and strict input validation
Derive an address from a public key, produce and check EIP-55 checksums, and validate user-supplied addresses, including the zero address.
5 min · Worked lesson
Account model versus UTXO: two ledgers and two ways to stop a double spend
Implement minimal UTXO and account ledgers in Go, reject double spends in each, and explain what each model makes easy or hard for an indexer.
5 min · Worked lesson
RLP: Ethereum's canonical encoding, and why its decoder rejects every other spelling
Encode and decode Go structs with go-ethereum's rlp package, recognize the canonical-form rules, and bound untrusted input before decoding it.
5 min · Worked lesson
Proof of work: finding a nonce takes thousands of hashes, checking it takes one
Mine a toy block against a big.Int target, verify it with one hash, compute its expected work and retarget from observed block times.
5 min · Worked lesson
Fork choice and reorgs: follow the heaviest chain and undo what the old branch indexed
Implement a heaviest-chain fork-choice rule, compute a reorganization's undo and apply path, apply confirmation depth, and use Ethereum's safe and finalized tags.
5 min · Worked lesson
Unit 2. Blockchain infrastructure
Package roles, RPC, exact units, ABI, nonces, key custody, reorg-safe indexing, fees, raw transactions, receipts, message signing and providers.
Go in blockchain: choose packages by the protocol and the job
Distinguish RPC applications, transaction tooling and consensus/application frameworks.
3 min · Worked lesson
Ethereum RPC: verify the chain and bound every operation
Use an explicit RPC client, operation deadline and expected chain identity.
3 min · Worked lesson
Token amounts: parse exact base units without float64
Convert validated decimal text to bounded integer base units with an explicit scale.
3 min · Worked lesson
Contract ABI: encoding is not permission and eth_call is not a transaction
Distinguish ABI packing, read simulation, signed transactions and deployment identity.
3 min · Worked lesson
Nonces, fees and unknown outcomes: one durable owner per account
Coordinate transaction intent and account nonce allocation before retrying a send.
3 min · Worked lesson
Signing policy: bind the chain and keep key custody separate
Validate transaction intent before delegating signing to an explicitly owned key service.
3 min · Worked lesson
Index events through disconnects and reorgs, not just the happy subscription
Persist canonical checkpoints and reconcile removed or missing events before final effects.
3 min · Worked lesson
EIP-1559 fees: compute the effective gas price exactly and refuse to sign above a ceiling
Derive maxFeePerGas and maxPriorityFeePerGas with big.Int, predict the effective gas price for any base fee and enforce a fee ceiling before signing.
6 min · Worked lesson
Raw transactions offline: sign, encode, decode and recover the sender before anything is broadcast
Sign a typed transaction with a test key, round-trip its raw bytes, recover the sender and use the precomputed hash to make retries safe.
5 min · Worked lesson
Receipts and logs: decode ERC-20 transfers from the right contract and reverse them on reorg
Interpret receipt status and gas, decode an ERC-20 Transfer log with accounts/abi, and reject impostor or removed logs before crediting a balance.
5 min · Worked lesson
Signed messages and Sign-In with Ethereum: recover the right address and refuse replays
Verify an EIP-191 personal signature, normalize its V byte, and accept an EIP-4361 sign-in only for this domain, chain and expiry with an unused server nonce.
5 min · Worked lesson
Several RPC providers: pin reads to one block hash, outvote a lagging or lying node, retry within bounds
Pin multi-provider reads to an agreed block hash, quarantine providers that disagree or lag, and fail over with bounded retries and backoff.
5 min · Worked lesson
Related: Secrets, cryptography and supply chain · Patterns: concurrent Go