Skip to content

nehirsunargs/token-gated-dapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Token-Gated Content DApp

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

Prerequisites

  • Node.js
  • MetaMask
  • Hardhat (installed locally in /gated-contract)
  • An Ethereum node or testnet endpoint (e.g., Hardhat local node, Alchemy, Infura)

Setup Instructions

Hardhat Contract Environment

  1. Navigate to the contract folder:

    cd gated-contract
  2. Install dependencies:

    npm install
  3. Start Hardhat local node (for local testing):

    npx hardhat node
  4. Deploy your contract:

    npx hardhat run scripts/deploy.js --network localhost

How It Works

  • 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.

Customize

  • Change the ETH minimum balance threshold by editing parseEther("1") in src/App.js.
  • Update contract address or ABI in environment variables if you integrate NFT or other token gating.

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors