This project implements a simple Ethereum Sepolia Faucet contract using Solidity and Hardhat. The Faucet allows users to withdraw a limited amount of ETH at once and ensures that the contract is funded upon deployment. It includes automated tests for contract functionality and integrates Hardhat Ignition for deployment management.
The Faucet.sol
contract allows users to:
- Withdraw a maximum of 0.25 ETH at a time.
- Check the contract's balance.
- Send ETH sent to the contract.
The contract is initialized with exactly 1 ETH at deployment to provide initial funds.
Ensure that you have the following installed:
-
Clone the repository:
git clone https://github.com/yourusername/faucet-contract cd faucet-contract
-
Install dependencies:
npm install
-
Do required changes in .env
-
Compile the contract:
npx hardhat compile
-
To ensure that the contract works as expected, run the test suite:
npx hardhat test
-
The test case cover:
- Successful withdrawal of 0.25 ETH.
- Failed withdrawal attempts exceeding 0.25 ETH.
- Verifying the contract can receive ETH.
This project uses Hardhat Ignition for deployment management. To deploy the contract with an initial funding of 1 ETH:
- Update your Hardhat network configuration with a funded account.
- Run the deployment script:
npx hardhat node // Open a new terminal and use any one 1. npx hardhat ignition deploy ./ignition/modules/Faucet.js --network localhost or 2. npx hardhat ignition deploy ./ignition/modules/Faucet.js --network <your-network>
The tests are located in test/Faucet.js and include:
- Withdraw Success: Allows the user to withdraw 0.25 ETH.
- Withdraw Failure: Ensures withdrawals exceeding 0.25 ETH are rejected.
- Receive ETH: Verifies that the contract can receive ETH and reflect it in the balance.
- This project is licensed under the MIT License - see the LICENSE