Week 12 / Blockchain from zero
Capstone: Build And Deploy A dApp
- Week 12 of Blockchain from zero
- Turn twelve weeks of learning into one working dApp.
Week 12 · Blockchain
What You Can Do By The End
- Scope a small dApp
- Write, test and deploy a contract
- Connect a web page with ethers.js
- Present a live demo
- Review a peer's work
Week 12 · Blockchain
Recap Of Week 11
- Test whether a use case needs a chain.
- Intermediaries are where rules apply.
- Public goods funding and identity are real uses.
- Nothing here is legal advice.
Week 12 · Blockchain
The Brief
- One contract plus one simple web page.
- Deployed and verified on Sepolia.
- Source code in a repository.
- Five-minute demo and one-page design note.
Week 12 · Blockchain
Project Ideas
- Tip jar with notes.
- Crowdfunding pot with goal and deadline.
- Attendance badge token.
- Voting with one vote per address.
| Idea | Core feature |
|---|
| Tip jar | Notes with ether |
| Crowdfunding | Goal and deadline |
| Attendance badge | Token per attendee |
| Voting | One vote per address |
Week 12 · Blockchain
Scope In One Sentence
- Who uses it, and what do they do?
- Why does a chain help?
- Apply the week 11 test honestly.
- If a database wins, change the idea.
Week 12 · Blockchain
Design On Paper First
- State: what the contract stores.
- Functions: three to five, with callers.
- Events: what the outside world sees.
- Trust: admin keys and failure cases.
state: tips[address] -> amount
functions: tip(note), withdraw()
events: Tipped(from, amount, note)
trust: owner can withdraw all
Week 12 · Blockchain
Reference Contract, Part One
- Fixed Solidity version.
- Owner is set once and never changes.
- An event records each tip.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract TipJar {
address public immutable owner;
mapping(address => uint256) public tips;
event Tipped(address indexed from, uint256 amount, string note);
constructor() { owner = msg.sender; }
}Week 12 · Blockchain
Reference Contract, Part Two
- tip accepts ether and a note.
- withdraw checks the owner first.
- Balance is sent only after checks.
function tip(string calldata note) external payable {
require(msg.value > 0, "send some ether");
tips[msg.sender] += msg.value;
emit Tipped(msg.sender, msg.value, note);
}
function withdraw() external {
require(msg.sender == owner, "only owner");
(bool ok, ) = owner.call{value: address(this).balance}("");
require(ok, "withdraw failed");
}Week 12 · Blockchain
Test Before You Deploy
- Normal calls from two accounts.
- Failing calls: zero value, non-owner withdraw.
- Automated tests in Foundry or Hardhat.
- One test that tries to break your rule.
Week 12 · Blockchain
Deploy And Verify
- Fresh wallet with only test coins.
- Fund it from a Sepolia faucet.
- Deploy, then save address and transaction hash.
- Verify the source on the explorer.
Week 12 · Blockchain
Connect The Web Page
- BrowserProvider connects to the wallet.
- A signer sends transactions.
- A Contract object needs address and ABI.
- Wait for the transaction, then update the page.
import { BrowserProvider, Contract, parseEther } from "ethers";
const abi = ["function tip(string note) payable"];
const provider = new BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
const jar = new Contract(ADDRESS, abi, signer);
const tx = await jar.tip("thanks", { value: parseEther("0.001") });
await tx.wait();20 points
Rubric
- Purpose and fit: 4 points.
- Contract quality and safety: 4 points.
- Deployment and verification: 4 points.
- Web interaction: 4 points.
- Demo and explanation: 4 points.
| Criterion | Points |
|---|
| Purpose and fit | 4 |
| Contract safety | 4 |
| Deployment | 4 |
| Web interaction | 4 |
| Demo | 4 |
Week 12 · Blockchain
Demo Script, Five Minutes
- Minute 1: the problem and why a chain helps.
- Minutes 2 and 3: live connect, read, write, explorer.
- Minute 4: the three key functions and the access rule.
- Minute 5: trust assumptions, one risk, next step.
Week 12 · Blockchain
Review Checklist
- Can I state the purpose and the need for a chain?
- Is the contract verified and does the transaction match?
- Does every state change have an access rule and an event?
- Do tests cover a failing case?
- Are trust assumptions written down?
Week 12 · Blockchain
Recap And What Comes Next
- You moved from money and trust to a deployed dApp.
- Keep building small and verify everything.
- Next steps: audits, mainnet readiness, community.
- Keep practicing on test networks.
Week 12 · Blockchain
Questions And Lab
- Build time: contract, deploy, web page.
- Pairs review each other using the checklist.
- Demos start after the lab block.