This project is a decentralized and tamper-proof NFT raffle system using Ethereum smart contracts. Leveraging the security and randomness provided by Chainlink VRF (Verifiable Random Function) and automated execution by Chainlink Keepers, this raffle system ensures fair selection of winners and trustless operation. Additionally, it integrates an NFT minting feature, where winners can be awarded unique NFTs as prizes.
- Entrance Fee: Participants must pay an entrance fee to enter the raffle.
- Chainlink VRF: Utilizes Chainlink VRF for provably fair and verifiable random winner selection.
- Chainlink Keepers: Automated checking and execution of the raffle draw based on predefined conditions (e.g., time intervals).
- NFT Minting: Winners are awarded unique NFTs minted on-the-fly.
- Pausable: The contract can be paused and unpaused by the owner for maintenance or emergency stops.
- Ownership: Leveraging OpenZeppelin's
Ownable
for secure ownership management.
An ERC721 token that awards unique NFTs to raffle winners. It incorporates pausable functionality for increased control over the contract's operations.
The main raffle contract that handles participant entry, raffle draws, and NFT minting for winners. It uses Chainlink VRF for random number generation and Chainlink Keepers for automated execution.
- Node.js and npm
- An Ethereum wallet with Rinkeby testnet ETH
- A Chainlink subscription for VRF and Keepers
- Clone the repository:
git clone github.com/Am0rfu5/NFT-Raffle.git
- Install dependencies:
npm install
- Set up environment variables by renaming
example.env
to.env
and filling in your values.
Compile the smart contracts:
npx hardhat compile
Deploy the contracts to your desired network:
npx hardhat deploy --network rinkeby
Optionally, deploy mock contracts for testing:
npx hardhat deploy --tags mocks --network rinkeby
Start a local Hardhat node:
npx hardhat node
Interact with the deployed contract in the local network:
npx hardhat console --network localhost
Enter the raffle with the script provided:
npx hardhat run scripts/enterRaffle.js --network localhost
- Check the current block number on Rinkeby:
npx hardhat block-number --network Rinkeby
- Enter the Raffle (ensure you're connected to the correct network):
npx hardhat run scripts/enterRaffle.js --network rinkeby
- Enter Raffle: Participants enter the raffle by sending ETH above the entrance fee threshold.
- CheckUpKeep: Chainlink Keepers periodically check if the conditions for performing a draw are met.
- PerformUpKeep: If conditions are met, the raffle draw is executed, selecting a random winner.
- SafeMint: The winner's address is used to mint a unique NFT as a prize.
Contributions are welcome! Feel free to open pull requests or issues to suggest improvements or add new features.
This project is licensed under the MIT License - see the LICENSE file for details.