BC10: Capstone: a shared fund the group can trust

Lesson 4 of 5 · reading 15–25 minutes; practice and project time is on the module page

Project 3: an app on the network

🎯You'll be able to

Complete Project 3: an app that checks its network, keeps keys out of the code, shows exact balances and history, waits for confirmations, and explains every refusal in plain words.

🏠The everyday picture

A passbook printer at the bank: it checks it's connected to the right bank, prints exact amounts, marks new entries "pending" until they clear, and explains a refused withdrawal in words.

📘What it really is

📝A worked example

Input: test 06 failing on the starter: "Replacement transaction underpriced".

Steps:

  1. Read the test: block making is paused, three deposits are sent, then one block is made; it expects nonces 0, 1 and 2.
  2. Read the starter: each deposit asks the node for the latest nonce, which is still 0 because nothing has been mined.
  3. Wrap the wallet in ethers' NonceManager in loadWallet, let it assign nonces, and run npm run test:app.

Expected output: test 06 passes, and all three deposits are in the fund.

🌍Where it's used

📝Case scenario

A learner's app passed every test except 07: it showed "VM Exception while processing transaction: reverted with custom error..." to the member. They decoded the error data with the fund's interface and mapped NotMember and IsPaused to plain sentences, and the test passed.

🖱️Try it

With the practice network running and the contracts deployed, run npm run app -- deposit 0.1 without setting a key. Success: a clear message naming SAKHI_PRIVATE_KEY, and no key printed.

⚠️Common mistakes

🛠️For your project

Project 3's evidence: the output of npm run test:app with 8 passing, docs/app-notes.md, and the app's output against the practice network.

✅Quick check

Why did the starter's three deposits clash?

Show the answer

Each asked for the latest nonce before any was mined, so they shared one.

What should a member see when the fund is paused?

Show the answer

A plain sentence saying the fund is paused by the admin, with no codes.

← PreviousProject 2: a multi-signature vault
ProLearners Assist