Skip to content

Commit d21c0d7

Browse files
committed
Initial commit
0 parents  commit d21c0d7

30 files changed

+12037
-0
lines changed

.commitlintrc.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ["@commitlint/config-conventional"],
3+
};

.czrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"path": "cz-conventional-changelog"
3+
}

.editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# EditorConfig http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# All files
7+
[*]
8+
charset = utf-8
9+
end_of_line = lf
10+
indent_size = 2
11+
indent_style = space
12+
insert_final_newline = true
13+
trim_trailing_whitespace = true
14+
15+
[*.sol]
16+
indent_size = 4

.env.example

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
INFURA_API_KEY=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
2+
MNEMONIC=here is where your twelve words mnemonic should be put my friend

.eslintignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# folders
2+
artifacts/
3+
build/
4+
cache/
5+
coverage/
6+
dist/
7+
lib/
8+
node_modules/
9+
typechain/
10+
11+
# files
12+
.solcover.js
13+
coverage.json

.eslintrc.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
extends:
2+
- "eslint:recommended"
3+
- "plugin:@typescript-eslint/eslint-recommended"
4+
- "plugin:@typescript-eslint/recommended"
5+
- "prettier"
6+
parser: "@typescript-eslint/parser"
7+
parserOptions:
8+
project: "tsconfig.json"
9+
plugins:
10+
- "@typescript-eslint"
11+
root: true
12+
rules:
13+
"@typescript-eslint/no-floating-promises":
14+
- error
15+
- ignoreIIFE: true
16+
ignoreVoid: true
17+
"@typescript-eslint/no-inferrable-types": "off"
18+
"@typescript-eslint/no-unused-vars":
19+
- error
20+
- argsIgnorePattern: _
21+
varsIgnorePattern: _

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.sol linguist-language=Solidity

.github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
custom: ["https://gitcoin.co/grants/1657/paulrberg-open-source-engineering"]

.gitignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# folders
2+
.coverage_artifacts/
3+
.coverage_cache/
4+
.coverage_contracts/
5+
artifacts/
6+
build/
7+
cache/
8+
coverage/
9+
dist/
10+
lib/
11+
node_modules/
12+
typechain/
13+
14+
# files
15+
*.env
16+
*.log
17+
*.tsbuildinfo
18+
coverage.json
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*

.huskyrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"hooks": {
3+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
4+
}
5+
}

.prettierignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# folders
2+
artifacts/
3+
build/
4+
cache/
5+
coverage/
6+
dist/
7+
lib/
8+
node_modules/
9+
typechain/
10+
11+
# files
12+
coverage.json

.prettierrc

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"arrowParens": "avoid",
3+
"bracketSpacing": true,
4+
"endOfLine":"auto",
5+
"printWidth": 120,
6+
"singleQuote": false,
7+
"tabWidth": 2,
8+
"trailingComma": "all",
9+
"overrides": [
10+
{
11+
"files": "*.sol",
12+
"options": {
13+
"tabWidth": 4
14+
}
15+
}
16+
]
17+
}

.solcover.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const shell = require("shelljs");
2+
3+
// The environment variables are loaded in hardhat.config.ts
4+
const mnemonic = process.env.MNEMONIC;
5+
if (!mnemonic) {
6+
throw new Error("Please set your MNEMONIC in a .env file");
7+
}
8+
9+
module.exports = {
10+
istanbulReporter: ["html", "lcov"],
11+
onCompileComplete: async function (_config) {
12+
await run("typechain");
13+
},
14+
onIstanbulComplete: async function (_config) {
15+
// We need to do this because solcover generates bespoke artifacts.
16+
shell.rm("-rf", "./artifacts");
17+
shell.rm("-rf", "./typechain");
18+
},
19+
providerOptions: {
20+
mnemonic,
21+
},
22+
skipFiles: ["mocks", "test"],
23+
};

.solhint.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"extends": "solhint:recommended",
3+
"plugins": ["prettier"],
4+
"rules": {
5+
"code-complexity": ["error", 7],
6+
"compiler-version": ["error", "^0.8.0"],
7+
"const-name-snakecase": "off",
8+
"constructor-syntax": "error",
9+
"func-visibility": ["error", { "ignoreConstructors": true }],
10+
"max-line-length": ["error", 120],
11+
"not-rely-on-time": "off",
12+
"prettier/prettier": [
13+
"error",
14+
{
15+
"endOfLine": "auto"
16+
}
17+
],
18+
"reason-string": ["warn", { "maxLength": 64 }]
19+
}
20+
}

.solhintignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# folders
2+
.yarn/
3+
build/
4+
dist/
5+
node_modules/

LICENSE.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# WTFPL
2+
3+
by Paul Razvan Berg (@PaulRBerg)
4+
5+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
6+
7+
0. You just DO WHAT THE FUCK YOU WANT TO.

README.md

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Solidity Template
2+
3+
My favourite setup for writing Solidity smart contracts.
4+
5+
- [Hardhat](https://github.com/nomiclabs/hardhat): compile and run the smart contracts on a local development network
6+
- [TypeChain](https://github.com/ethereum-ts/TypeChain): generate TypeScript types for smart contracts
7+
- [Ethers](https://github.com/ethers-io/ethers.js/): renowned Ethereum library and wallet implementation
8+
- [Waffle](https://github.com/EthWorks/Waffle): tooling for writing comprehensive smart contract tests
9+
- [Solhint](https://github.com/protofire/solhint): linter
10+
- [Solcover](https://github.com/sc-forks/solidity-coverage): code coverage
11+
- [Prettier Plugin Solidity](https://github.com/prettier-solidity/prettier-plugin-solidity): code formatter
12+
13+
This is a GitHub template, which means you can reuse it as many times as you want. You can do that by clicking the "Use this
14+
template" button at the top of the page.
15+
16+
## Usage
17+
18+
### Pre Requisites
19+
20+
Before running any command, make sure to install dependencies:
21+
22+
```sh
23+
$ yarn install
24+
```
25+
26+
### Compile
27+
28+
Compile the smart contracts with Hardhat:
29+
30+
```sh
31+
$ yarn compile
32+
```
33+
34+
### TypeChain
35+
36+
Compile the smart contracts and generate TypeChain artifacts:
37+
38+
```sh
39+
$ yarn typechain
40+
```
41+
42+
### Lint Solidity
43+
44+
Lint the Solidity code:
45+
46+
```sh
47+
$ yarn lint:sol
48+
```
49+
50+
### Lint TypeScript
51+
52+
Lint the TypeScript code:
53+
54+
```sh
55+
$ yarn lint:ts
56+
```
57+
58+
### Test
59+
60+
Run the Mocha tests:
61+
62+
```sh
63+
$ yarn test
64+
```
65+
66+
### Coverage
67+
68+
Generate the code coverage report:
69+
70+
```sh
71+
$ yarn coverage
72+
```
73+
74+
### Report Gas
75+
76+
See the gas usage per unit test and average gas per method call:
77+
78+
```sh
79+
$ REPORT_GAS=true yarn test
80+
```
81+
82+
### Clean
83+
84+
Delete the smart contract artifacts, the coverage reports and the Hardhat cache:
85+
86+
```sh
87+
$ yarn clean
88+
```
89+
90+
### Deploy
91+
92+
Deploy the contracts to Hardhat Network:
93+
94+
```sh
95+
$ yarn deploy
96+
```
97+
98+
Deploy the contracts to a specific network, such as the Ropsten testnet:
99+
100+
```sh
101+
$ yarn deploy:network ropsten
102+
```
103+
104+
## Syntax Highlighting
105+
106+
If you use VSCode, you can enjoy syntax highlighting for your Solidity code via the
107+
[vscode-solidity](https://github.com/juanfranblanco/vscode-solidity) extension. The recommended approach to set the
108+
compiler version is to add the following fields to your VSCode user settings:
109+
110+
```json
111+
{
112+
"solidity.compileUsingRemoteVersion": "v0.8.4+commit.c7e474f2",
113+
"solidity.defaultCompiler": "remote"
114+
}
115+
```
116+
117+
Where of course `v0.8.4+commit.c7e474f2` can be replaced with any other version.

contracts/Greeter.sol

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import "hardhat/console.sol";
5+
6+
contract Greeter {
7+
string public greeting;
8+
9+
constructor(string memory _greeting) {
10+
console.log("Deploying a Greeter with greeting:", _greeting);
11+
greeting = _greeting;
12+
}
13+
14+
function greet() public view returns (string memory) {
15+
return greeting;
16+
}
17+
18+
function setGreeting(string memory _greeting) public {
19+
console.log("Changing greeting from '%s' to '%s'", greeting, _greeting);
20+
greeting = _greeting;
21+
}
22+
}

0 commit comments

Comments
 (0)