This project consists of two Solidity smart contracts: SepoliaFaucet and BlockfuseNFT. These contracts allow users to claim Sepolia testnet ETH if they own an NFT from the BlockfuseNFT collection. The faucet distributes ETH once every 24 hours to eligible users.
This contract implements an ERC-721 NFT collection where each address can mint one unique NFT.
- Minting: Users can mint a single NFT to their address.
- Ownership Check: Ensures each address can only mint one NFT.
- Token Existence Check: Provides a function to check if a token ID exists.
mint(address to)
: Mints an NFT to the given address.exists(uint256 tokenId)
: Checks if a given token ID exists.
This contract distributes Sepolia ETH to users who own a BlockfuseNFT.
- NFT Ownership Check: Only users who own an NFT can claim ETH.
- Claim Restriction: Users can only claim once every 24 hours.
- ETH Withdrawal: The contract owner can withdraw all funds from the faucet.
- Funding Mechanism: Allows anyone to send ETH to the contract to fund the faucet.
claimETH()
: Allows NFT holders to claim 0.001 ETH once every 24 hours.ownsNFT(address user)
: Checks if the user owns at least one NFT.withdrawFunds()
: Allows the owner to withdraw the contract's balance.getBalance()
: Returns the contract's ETH balance.receive()
: Accepts ETH deposits to fund the faucet.
Deploy the BlockfuseNFT
contract first, as its address is required for deploying SepoliaFaucet
.
Deploy the SepoliaFaucet
contract, passing the address of BlockfuseNFT
as an argument to the constructor.
- Mint an NFT: Call
mint(address)
onBlockfuseNFT
to receive an NFT. - Fund the Faucet: Send ETH to the
SepoliaFaucet
contract. - Claim ETH: Call
claimETH()
onSepoliaFaucet
if you own an NFT. - Withdraw Funds: The owner can call
withdrawFunds()
to withdraw all funds from the faucet.
- Solidity
^0.8.28
- OpenZeppelin Contracts (
ERC721
,Ownable
,IERC721
) - A funded Sepolia account for deployment
- A blockchain development environment like Hardhat or Foundry
git clone https://github.com/your-username/nft-faucet.git
cd nft-faucet
npm install
npx hardhat compile
npx hardhat test
Create a .env file in the root directory and add:
SEPOLIA_RPC_URL=your_alchemy_api_key
PRIVATE_KEY=our_wallet_private_key
ETHERSCAN_API_KEY=your_etherscan_api_key
npx hardhat run scripts/deploy.ts --network sepolia
- Fork the repository
- Create a feature branch (git checkout -b feature-name)
- Commit your changes (git commit -m "Add feature X")
- Push to the branch (git push origin feature-name)
- Create a Pull Request
This project is licensed under the MIT License.