Just a convention to make a good-looking contract. :3
Feel free to apply it.
STRUCTURE
- src
/active: For working contracts
/interfaces: Contains all contract interface type
/libraries: Contains all library type
/utils: Contains all utility type
XXXToken.sol: ERC20 token, ...
XXXContract.sol: Your contract implementation
/archived: For reference, sample contract, etc
/stash: Temporary contract storage. This contract can be moved to `active` for deployment
FORMAT & LINT
- Format standard
"prettier": "^2.4.0",
"prettier-plugin-solidity": "^1.0.0-beta.18",
- Lint
"solhint": "^3.3.6",
"solhint-plugin-prettier": "^0.0.5"
- Verify before commit
// package.json
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "./node_modules/.bin/solhint -f table 'src/active/**/*.sol' -w 0",
"format": "./node_modules/.bin/prettier --write 'src/active/**/*.sol'",
"prepare": "husky install"
},
"devDependencies": {
....
"husky": "^7.0.2",
"prettier": "^2.4.0",
"prettier-plugin-solidity": "^1.0.0-beta.18",
"pretty-quick": "^3.1.1",
"solhint": "^3.3.6",
"solhint-plugin-prettier": "^0.0.5"
}
// .husky/pre-commit
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx pretty-quick --staged && npm run lint
COMMIT RULEs
- DO use Semantic Commit Messages: https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716
- DO use Git Branching Model: https://nvie.com/posts/a-successful-git-branching-model
- DO run format before commit
npm run format
- DO run lint before commit
npm run lint
CODING STYLE
Style guide: https://docs.soliditylang.org/en/v0.5.3/style-guide.html
Function description
Each function must have a description as format below
/**
* @notice It allows the owner can set presenter to token
* @dev This function is only callable by admin.
* Requirements:
* - .....
*
* @param _pPresenter: the address of the token to withdraw
* input == address(0) if…