BlockMSG is a Web3 learning app with a real on-chain demo.
It’s structured as three pages:
- Learn: rendered from a Markdown guide
- Deploy: how to deploy the contract + wire the frontend
- Demo: connect MetaMask and post/read a message from the blockchain
- How a React dApp talks to MetaMask via
window.ethereum - The difference between reads (free) and writes (cost gas)
- How to deploy a Solidity contract and pass its address to a frontend
- How to make static hosting work (Netlify / GitHub Pages) using environment-based config
- Smart contract:
contracts/MessageBoard.sol - Hardhat (v3): compile + deploy from the repo root
- Frontend: Vite + React in
frontend/- Uses hash-based routing so static hosts don’t need server rewrites
- Loads Learn content from
frontend/src/content/blockchain.md
- State:
message,lastWriter,lastUpdated - Write:
setMessage(string)(requires gas) - Read:
getMessage(),getMessageInfo()(free)
npm install
cd frontend
npm installIn the project root:
npx hardhat nodeIn another terminal (project root):
npx hardhat run scripts/deploy.js --network localhostThis writes the ABI + deployed address to frontend/src/contracts/MessageBoard.json.
cd frontend
npm run devOpen the app and go to:
/#/learn/#/deploy/#/demo
Create a .env file (do not commit it):
SEPOLIA_RPC_URL=https://...
DEPLOYER_PRIVATE_KEY=0x...npx hardhat compile
npx hardhat run scripts/deploy.js --network sepoliaThis repo includes netlify.toml with:
- base:
frontend - build:
npm run build - publish:
dist
Set these Netlify environment variables (so the hosted build talks to Sepolia):
SEPOLIA_RPC_URL= Your URLDEPLOYER_PRIVATE_KEY= Your private key
Important: Vite env vars are baked into the build output. Set them before building on Netlify.
contracts/Solidity contract(s)scripts/Hardhat deployment scripts (Hardhat v3 uses a viem-based deploy)frontend/React + Vite UIfrontend/src/pages/Learn / Deploy / Demo pagesfrontend/src/content/blockchain.mdLearn content source