A wallet-connected Web3 mini social app for publishing short posts directly into smart contract storage.
Live UI · Run Locally ·
ChainPosts is a simple decentralized application that lets users connect a wallet, write a short message, and publish it on-chain. The project was built as a hands-on Web3 club project to practice the full dApp workflow: smart contract development, frontend integration, wallet interaction, testing, debugging, and deployment.
- Wallet connect with MetaMask
- Short posts stored directly in contract storage
- 280-byte post limit enforced in Solidity
- Recent post feed pulled from the contract
- Dark and light mode UI
- Local Hardhat deployment flow
- Frontend hosted on Vercel
- User-friendly wallet and RPC error handling
- Solidity
- Hardhat
- Ethers.js
- React
- Vite
- Lucide React
- MetaMask
- Vercel
The contract in contracts/ChainPosts.sol exposes three core behaviors:
createPost(string content)stores a new post on-chaingetPost(uint256 id)returns a single post by idgetRecentPosts(uint256 count)returns the newest posts first
It also uses:
- custom errors for cleaner validation
PostCreatedevents for post creation trackingtotalPostsas an on-chain counter
- Install dependencies:
npm install- Start the local blockchain:
npm run node- In a new terminal, deploy the contract:
npm run deploy- Start the frontend:
npm run dev- Open the local app and connect MetaMask to:
- RPC URL:
http://127.0.0.1:8545 - Chain ID:
31337 - Currency symbol:
ETH
npm run compile
npm run test
npm run build
npm run deploy
npm run devcontracts/ Solidity smart contracts
scripts/ Hardhat deploy script
src/ React frontend
src/contracts/ Generated frontend contract metadata
test/ Contract tests
public/ Static assets including app branding
Live deployment note
The current Vercel deployment is available at chainposts-web3.vercel.app. When the hosted app detects that the bundled contract metadata points to local Hardhat, it lets the connected wallet deploy a fresh ChainPosts contract on the active wallet network instead of trying to use 127.0.0.1 from production.
For a shared public feed, deploy one contract to a public testnet and update:
VITE_POSTS_CONTRACT_ADDRESSVITE_EXPECTED_CHAIN_IDVITE_RPC_URL
Troubleshooting MetaMask and RPC issues
If publishing fails, check the following:
- MetaMask is connected to chain
31337 - the RPC URL is
http://127.0.0.1:8545 - the local Hardhat node is running
- the contract has been redeployed after restarting the chain
- the selected wallet has test ETH
The frontend also includes friendlier handling for common wallet errors such as:
- rejected wallet requests
- insufficient funds
- wrong network
- low-level RPC errors like
could not coalesce error
- writing and testing Solidity contracts
- contract storage and events
- wallet connection in frontend apps
- reading and writing with Ethers.js
- local blockchain development with Hardhat
- handling chain IDs, RPC endpoints, and deployment metadata
- shipping a Web3 frontend to production
