Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Chainlink lottery randomness #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions contracts/chainlink-lottery-randomness/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PRIVATE_KEY = <<YOUR_PRIVATE_KEY_HERE>>

ETHERSCAN_KEY = <<YOUR_ETHERSCAN_KEY_HERE>>
BSCSCAN_KEY = <<YOUR_BSCSCAN_KEY_HERE>>
POLYGONSCAN_KEY = <<YOUR_POLYGONSCAN_KEY_HERE>>
INFURA_API_KEY = <<YOUR_INFURA_API_KEY_HERE>>

17 changes: 17 additions & 0 deletions contracts/chainlink-lottery-randomness/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "prettier"],
"extends": ["plugin:@typescript-eslint/recommended", "prettier"],
"rules": {
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
]
}
}
2 changes: 2 additions & 0 deletions contracts/chainlink-lottery-randomness/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
137 changes: 137 additions & 0 deletions contracts/chainlink-lottery-randomness/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
coverage.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# smart contract
test-results/
typechain-types/
cache/
artifacts/
.husky/

.DS_Store
contracts.json
9 changes: 9 additions & 0 deletions contracts/chainlink-lottery-randomness/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**/.git
**/.svn
**/.hg
**/node_modules
**/artifacts
**/cache
**/coverage
**/test-results
**/typechain-types
8 changes: 8 additions & 0 deletions contracts/chainlink-lottery-randomness/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tabWidth": 4,
"singleQuote": false,
"trailingComma": "all",
"printWidth": 80,
"plugins": ["prettier-plugin-solidity"],
"endOfLine": "lf"
}
6 changes: 6 additions & 0 deletions contracts/chainlink-lottery-randomness/.solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
skipFiles: [
"./contracts/DPNFT.sol",
"./contracts/libraries/PriceConverter.sol",
],
};
11 changes: 11 additions & 0 deletions contracts/chainlink-lottery-randomness/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error",
"compiler-version": ["error", "^0.8.0"],
"func-visibility": ["warn", { "ignoreConstructors": true }],
"reason-string": "off",
"not-rely-on-time": "off"
},
"extends": ["solhint:recommended"]
}
1 change: 1 addition & 0 deletions contracts/chainlink-lottery-randomness/.solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
94 changes: 94 additions & 0 deletions contracts/chainlink-lottery-randomness/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Lottery Randomness with ChainLink

## Usage

### Pre Requisites

Before being able to run any command, you need to create a `.env` file and set a BIP-39 compatible mnemonic as an
environment variable. You can follow the example in `.env.example`. If you don't already have a mnemonic, you can use
this [website](https://iancoleman.io/bip39/) to generate one.

Then, proceed with installing dependencies:

```sh
$ yarn install
```

### Compile

Compile the smart contracts with Hardhat:

```sh
$ yarn compile
```

### TypeChain

Compile the smart contracts and generate TypeChain bindings:

```sh
$ yarn typechain
```

### Test

Run the tests with Hardhat:

```sh
$ yarn test
```

### Lint Solidity

Lint the Solidity code:

```sh
$ yarn lint:sol
```

### Lint TypeScript

Lint the TypeScript code:

```sh
$ yarn lint:ts
```

### Coverage

Generate the code coverage report:

```sh
$ yarn coverage
```

### Report Gas

See the gas usage per unit test and average gas per method call:

```sh
$ REPORT_GAS=true yarn test
```

### Clean

Delete the smart contract artifacts, the coverage reports and the Hardhat cache:

```sh
$ yarn clean
```

### Deploy

Deploy the contracts to Hardhat Network:

```sh
$ yarn deploy --greeting "Bonjour, le monde!"
```

### Fix husky not executable

```sh
chmod ug+x .husky/*
chmod ug+x .git/hooks/*
```
Loading