A decentralized application (DApp) that gates content access based on Ethereum wallet balance. Users must hold at least 1 ETH to view protected content.
This project includes:
-
A Hardhat smart contract development environment for deploying contracts
-
A React frontend app that connects to MetaMask, checks wallet ETH balance, and conditionally grants access
- Node.js
- MetaMask
- Hardhat (installed locally in
/gated-contract) - An Ethereum node or testnet endpoint (e.g., Hardhat local node, Alchemy, Infura)
-
Navigate to the contract folder:
cd gated-contract -
Install dependencies:
npm install
-
Start Hardhat local node (for local testing):
npx hardhat node
-
Deploy your contract:
npx hardhat run scripts/deploy.js --network localhost
- The React app connects to MetaMask and retrieves the user's wallet address.
- It queries the Ethereum provider to get the ETH balance of that address.
- If the balance is ≥ 1 ETH, the user gets access to the gated content.
- Otherwise, access is denied.
- Change the ETH minimum balance threshold by editing
parseEther("1")insrc/App.js. - Update contract address or ABI in environment variables if you integrate NFT or other token gating.
MIT License