BC7: Writing smart contracts in Solidity

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

Tools, versions and other languages

🎯You'll be able to

Compile, test and deploy with Hardhat, and explain where Vyper and Rust fit.

🏠The everyday picture

A workshop has a bench (where you build), a test rig (where you try), and a delivery van (how it leaves). You use all three every time.

📘What it really is

📝A worked example

Input: compile and test SakhiFund from the kit.

Steps:

  1. npm run compile: Hardhat compiles with the pinned solc, without downloading anything.
  2. npm run test:contract: runs Project 1's 10 tests on a fresh in-process network.
  3. npm run chain and npm run deploy:local: deploys to the practice network for the app.

Expected output: a repeatable build, test and deploy.

🌍Where it's used

📝Case scenario

A team couldn't verify its deployed contract on an explorer because nobody had recorded the compiler version and optimiser settings used. Users couldn't check the code, and trust suffered. Pinning versions in the project's settings, and keeping deployment records, made later releases verifiable.

🖱️Try it

Open hardhat.config.js and write down the compiler version and optimiser settings. Success: 0.8.38, optimiser on, 200 runs.

⚠️Common mistakes

🛠️For your project

All three projects run with npm test. The capstone's design notes can mention other languages, but the kit uses Solidity only.

✅Quick check

Why pin the compiler version?

Show the answer

So everyone gets the same bytecode, and the deployed contract can be verified.

Where is Rust used for smart contracts?

Show the answer

For Solana programs and on some other chains.

← PreviousHandling ether safely
ProLearners Assist