https://github.com/ambersun1234/lottery-raffle-contract
Smart contract for lottery raffle
https://github.com/ambersun1234/lottery-raffle-contract
integration-test smart-contracts solidity typescript unit-test
Last synced: about 1 year ago
JSON representation
Smart contract for lottery raffle
- Host: GitHub
- URL: https://github.com/ambersun1234/lottery-raffle-contract
- Owner: ambersun1234
- License: mit
- Created: 2023-02-08T04:39:51.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-09-01T01:12:11.000Z (almost 2 years ago)
- Last Synced: 2025-05-20T03:12:29.833Z (about 1 year ago)
- Topics: integration-test, smart-contracts, solidity, typescript, unit-test
- Language: TypeScript
- Homepage:
- Size: 1.15 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lottery Raffle Contract
This project implements simple lottery contract with chainlink keeper and vrf
## Description
This smart contract will choose one winner in a time interval(default for `30 seconds`, change the default value in [helper-hardhat.config.ts](./helper-hardhat.config.ts))\
User can pay at least `0.1 goerli ETH` entrance fee to play the raffle, and after 30 seconds, the smart contract will automatically pick a winner(by chainlink keeper and vrf)\
All of the entrance fee will be send to winner's crypto wallet
## Prerequisite
```
$ yarn install
```
## Note
In order to use the contract on the testnet correctly, you will need to set up [chainlink keeper](https://automation.chain.link/) and [chainlink vrf](https://vrf.chain.link/) correctly\
After you setup the keeper and vrf, grab the vrf subscription id and place it into `subscriptionID`(inside `NetworkConfig.5`) in [helper-hardhat.config.ts](./helper-hardhat.config.ts)
## Deploy to Goerli Testnet
```
$ yarn hardhat deploy --network goerli
```
## Test
### Unit Test
```
$ yarn hardhat test
```
### Integration Test
```
$ yarn hardhat test --network goerli
```
## Code Coverage
```
$ yarn hardhat coverage
```
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
---------------------------|----------|----------|----------|----------|----------------|
contracts/ | 94.74 | 90 | 92.86 | 94.74 | |
Lottery.sol | 94.74 | 90 | 92.86 | 94.74 | 81,146 |
VRFCoordinatorV2Mock.sol | 100 | 100 | 100 | 100 | |
---------------------------|----------|----------|----------|----------|----------------|
All files | 94.74 | 90 | 92.86 | 94.74 | |
---------------------------|----------|----------|----------|----------|----------------|
## License
This project is licensed under MIT License - see the [LICENSE](./LICENSE) file for detail