This project is a decentralized application (DApp) built with Next.js and Solidity. It allows users to participate in a lottery where a winner is picked randomly using Chainlink VRF (Verifiable Random Function).
- Deployments
- Access the Website hosted on IPFS
- Installation
- Usage
- Features
- Technologies Used
- Deploy
- Contributing
- License
- IPFS through Fleek: ipfs://bafybeihwxbv3fpgdqqpivob5xen63cdolv6ihobetmpmxshhwcd76nx5gq (You need to have an IPFS extension enabled)
- Fleek: https://fat-gpu-crooked.on-fleek.app/
Deployed using only IPFS Desktop:
To see the website directly on IPFS, you need to have IPFS Desktop running or a local IPFS node enabled.
You can simply use the Brave IPFS node or install the IPFS Companion Extension.
Install the IPFS Companion Extension from the Chrome Web Store.
Install the IPFS Companion Extension from Firefox Browser ADD-ONS.
Read the IPFS Companion Install Documentation to install the IPFS Companion on your preferred browser.
To set up the project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/your-username/nextjs-smartcontract-lottery.git cd nextjs-smartcontract-lottery
-
Install dependencies:
yarn install
-
Spin Up hardhat node
hardhat is not installed in this repository
So you must do one of the following:
- Have your own hardhat project.
- Create a new hardhat project following the hardhat official documentation.
- Clone my repository hardhat-smartcontract-lottery and follow the instructions in the README.md .
Now run
hardhat node
-
Run the development server:
yarn dev
Open http://localhost:3000 with your browser to see the result.
- Connect Wallet: Click on the "Connect Wallet" button to connect your Ethereum wallet.
- Switch Network: If you are not on the Sepolia network, you will be prompted to switch.
- Enter Lottery: Enter the lottery by paying the entrance fee.
- Check Winner: The winner is picked randomly using Chainlink VRF.
- Decentralized Lottery: Participate in a fair and transparent lottery.
- Chainlink VRF: Ensures the randomness of the winner selection.
- Wallet Integration: Connect your Ethereum wallet to interact with the DApp.
- Network Switching: Automatically prompts the user to switch to the Sepolia network if not already connected.
- Next.js: React framework for server-side rendering and static site generation.
- Solidity: Programming language for writing smart contracts.
- Chainlink VRF: Verifiable Random Function for generating random numbers.
- Web3uikit: UI components for Web3 applications.
- Moralis: Simplifies interaction with blockchain data.
- IPFS Desktop
To install the correct version of IPFS Desktop, please read the docs Install the IPFS Desktop App.
From the root repository (nextjs-smartcontract-lottery), run in the terminal:
yarn build
This will automatically export the static version of the website in the newly created "out" directory.
Check out Next.js documentation for Static Exports to learn more.
Now:
- Open IPFS Desktop
- Click the "FILES" tab on the right
- Click the Import Button
- Select the "out" directory created after running
yarn build
Congrats! Now your website is officially hosted on IPFS
Check out your website on your favorite browser!
In IPFS Desktop, Files Tab:
- Click the three dots on the right of the "out" directory
- Click on "Copy CID"
- Open your preferred browser
- Paste the CID preceded by "ipfs://"
Deploying on Fleek is easier and helps other nodes pinning our Website. Fleek deploys both on IPFS and on regular hosting.
- Navigate to Fleek
- Sign up with your wallet
- Click on "Deploy your Site"
- Click on "Add New" -> "Deploy my site"
- Click on GitHub, after authorizing you will be prompted to install "Fleek" on GitHub, do it
- Now select the cloned "nextjs-smartcontract-lottery" repository
- Click on "Deploy"
Now just wait for the deployment to finish.
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.