Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nawodyaishan/hardhat-smart-contract-lottery
"Hardhat Smart Contract Lottery" is a blockchain project that leverages Ethereum smart contracts to implement a lottery system. Developed using Hardhat, this project provides a comprehensive setup for Solidity development, testing, and deployment.
https://github.com/nawodyaishan/hardhat-smart-contract-lottery
bun chainlink chainlink-keepers chainlink-vrf ethereum ethers hardhat solidity typescript vrfcoordinatorv2interface web3
Last synced: about 1 month ago
JSON representation
"Hardhat Smart Contract Lottery" is a blockchain project that leverages Ethereum smart contracts to implement a lottery system. Developed using Hardhat, this project provides a comprehensive setup for Solidity development, testing, and deployment.
- Host: GitHub
- URL: https://github.com/nawodyaishan/hardhat-smart-contract-lottery
- Owner: nawodyaishan
- Created: 2024-01-05T02:15:09.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-02-19T01:42:28.000Z (10 months ago)
- Last Synced: 2024-04-14T02:08:31.166Z (8 months ago)
- Topics: bun, chainlink, chainlink-keepers, chainlink-vrf, ethereum, ethers, hardhat, solidity, typescript, vrfcoordinatorv2interface, web3
- Language: TypeScript
- Homepage:
- Size: 1.51 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Hardhat Smart Contract Lottery
This Ethereum project provides a decentralized, transparent lottery system built using Solidity and the Hardhat development environment. It leverages Chainlink VRF for secure randomness in winner selection.
**Prerequisites**
* Node.js ([https://nodejs.org/](https://nodejs.org/))
* Bun ([https://bun.sh/](https://bun.sh/))
* Knowledge of Solidity and smart contract development fundamentals.
* Experience with Hardhat for development and testing.
* Understanding of Chainlink VRF for a verifiable source of randomness.**Setup**
1. **Clone the Repository:**
```bash
git clone https://github.com/nawodyaishan/hardhat-smart-contract-lottery.git
cd hardhat-smart-contract-lottery
```2. **Install Dependencies:**
```bash
bun install
```3. **Environment Variables:**
* Create a `.env` file in the project root (not tracked by version control).
* Use this file to store:
* API Keys: Etherscan, Infura, CoinMarketCap.
* Network RPC URLs (Sepolia, Mainnet, etc.).
* Private keys or mnemonic phrases for testing and deployment.**Core Smart Contracts**
* **Raffle.sol**
* Entry management (purchase tickets).
* Chainlink VRF integration to obtain provably random numbers.
* Automated winner selection logic.
* Distribution of the prize pool to the winner.* **VRFCoordinatorV2Mock.sol**
* Implements essential VRF functionality for local development and testing.**Essential Hardhat Tasks**
* `bun run compile`: Compiles smart contracts.
* `bun run test`: Executes the test suite.
* `bun run deploy:contracts`: Deploys to the specified network.
* `bun run verify`: Verifies contracts on Etherscan (use `--network networkName`).**Development Workflow**
1. **Modify Contracts:** Update Solidity contracts in the `contracts/` directory.
2. **Write Tests:** Write comprehensive tests in the `test/` directory using Mocha/Chai.
3. **Local Testing:**
* `bun run deploy:contracts --network hardhat`
* Interact with the contracts, and check test results.
4. **Testnet Deployment:**
* Configure target testnet in `hardhat.config.ts`
* Obtain testnet ETH via faucets.
* Deploy using `bun run deploy:contracts --network `
5. **Verification:** Verify contracts on Etherscan using `bun run verify`.