Adding a Tip Jar to a Webpage

The previous tutorials drove the TipJar contract entirely from the shell. This one puts it behind a webpage: a Connect button, a tip form, a live balance, and a withdraw button that only appears for the owner. The browser flow is: Webpage → ethers.js → MetaMask → Anvil → TipJar contract MetaMask holds the keys and signs the transactions. No private key goes anywhere near the JavaScript. Frontend source is visible to anyone who visits the page, so a key in it is a key you have given away. ...

August 15, 2026 · 13 min · 2624 words

Invariant Testing with Foundry

Unit tests check that a function does what you expected. Invariant tests check something harder: that a property of your contract holds no matter what anybody does to it. This tutorial writes both kinds against a TipJar contract, watches the invariant catch a bug every unit test missed, and then shows why the obvious invariant is still wrong. It follows on from Writing a Smart Contract with Foundry, and picks up exactly where that one ends. Its sibling, Adding a Tip Jar to a Webpage, takes the same contract in the other direction and puts a browser frontend on it. Neither depends on the other. ...

August 15, 2026 · 8 min · 1643 words

Writing a Smart Contract with Foundry

This tutorial writes, tests, deploys, and drives a TipJar smart contract entirely from the command line. It follows on from Ethereum from the Command Line, which covers Anvil, accounts, transactions, and blocks. You do not have to have read it — the Prerequisites below get you to the same starting point — but it explains most of what this one assumes. Two tutorials follow on from this one: Adding a Tip Jar to a Webpage puts a frontend on the contract, and Invariant Testing with Foundry tests it harder. ...

August 15, 2026 · 26 min · 5514 words

Ethereum from the Command Line

This tutorial explores an Ethereum blockchain entirely from the shell — accounts, transactions, blocks, gas, and units — using a local test chain and then the real network. There is no Solidity here, and no frontend. Writing and deploying a contract is the subject of the follow-up, Writing a Smart Contract with Foundry. Ethereum A blockchain is a shared, append-only ledger that nobody owns. What makes one programmable is the ability to put code on it — a smart contract, which is a program with its own address, its own storage, and its own balance. Once deployed, it runs exactly as written for anyone who calls it, and no single party can quietly change it or stop it. ...

August 15, 2026 · 28 min · 5770 words