Skip to content

kadekdodikwirawan/web3-verifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Web3 Domain Verifier

A learning project for Web3 development featuring a Solidity smart contract (with upgradeable pattern) and a React frontend that allows users to verify domain ownership on the Ethereum blockchain.

🔗 Live Demo: https://web3-verifier.netlify.app/

📁 Project Structure

web3-verifier/
├── hardhat/          # Smart contract development
│   ├── contracts/    # Solidity contracts
│   ├── scripts/      # Deployment scripts
│   ├── test/         # Contract tests
│   └── ignition/     # Hardhat Ignition modules
│
└── frontend/    # React frontend
    ├── src/          # React components & utilities
    └── public/       # Static assets

🧠 What You'll Learn

  • Solidity Smart Contracts: Writing, compiling, and deploying contracts
  • Upgradeable Contracts: Using OpenZeppelin's upgradeable patterns
  • Hardhat Development: Testing, deploying, and interacting with contracts
  • React + Ethers.js: Building a dApp frontend
  • MetaMask Integration: Wallet connection and transaction signing
  • Domain Verification: On-chain proof of domain ownership

🚀 Getting Started

Prerequisites

1. Smart Contract Setup (Hardhat)

cd hardhat
npm install

Compile Contracts

npx hardhat compile

This generates the ABI (Application Binary Interface) in:

hardhat/artifacts/contracts/DomainVerifierV2.sol/DomainVerifierV2.json

Copy the "abi" array from this JSON file to frontend/src/utils/abi.ts for your frontend to interact with the contract.

Run Tests

npx hardhat test

Start Local Node

npx hardhat node

This creates 20 test accounts with 10,000 ETH each. You'll see output like:

Account #0: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 (10000 ETH)
Private Key: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

💡 These are Hardhat's well-known test accounts - safe to use for local development only.

Deploy to Local Network

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

Deploy to Sepolia Testnet

npx hardhat run scripts/deploy.ts --network sepolia

⚠️ Create a .env file with your private key and RPC URL for testnet deployment.


🔑 Getting Your Private Key

For Local Development

Use any of Hardhat's test accounts shown when running npx hardhat node.

For Sepolia Testnet

  1. Open MetaMask → Click on account name → "Account details"
  2. Click "Show private key"
  3. Enter your password and copy the key

Setting Up .env

Create a .env file in the hardhat/ folder:

SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/YOUR_PROJECT_ID
PRIVATE_KEY=your_private_key_here_without_0x_prefix

Get a free RPC URL from:

Get free test ETH from:

⚠️ Security Warning
Never commit .env files or share your private key!
Never use a wallet with real funds for development!

2. Frontend Setup (React + Vite)

cd frontend
npm install
npm run dev

The app will be available at http://localhost:5173


📜 Smart Contracts

DomainVerifier.sol

Basic domain verification contract:

  • verifyDomain(domain) - Add a domain to your verified list
  • getDomains(owner) - Get all domains verified by an address
  • removeDomain(domain) - Remove a domain from your list

DomainVerifierV2.sol (Upgraded)

Enhanced version with additional features:

  • Timestamps: Track when each domain was verified
  • Global Ownership: Prevent duplicate domain verification across users
  • getDomainOwner(domain) - Check who owns a domain
  • getDomainTimestamp(domain) - Get verification timestamp
  • getDomainsWithTimestamps(owner) - Get domains with their timestamps

🔧 Technologies Used

Smart Contract

  • Solidity - Smart contract language
  • Hardhat - Development environment
  • OpenZeppelin Contracts - Secure, audited contract libraries
  • TypeChain - TypeScript bindings for contracts

Frontend

  • React 19 - UI framework
  • Vite - Build tool
  • Ethers.js - Ethereum library
  • TailwindCSS - Styling
  • FontAwesome - Icons

📖 Learning Resources


🔐 Security Notes

⚠️ This is a learning project. Do NOT use in production without proper auditing.

  • Never commit private keys or .env files
  • Always test on testnets before mainnet
  • Consider gas optimization for production contracts
  • Implement proper access control for sensitive functions

📝 License

MIT License - Feel free to use this for learning purposes!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published