Solidity Smart Contract Convention X

Nhan Cao
3 min readMar 14, 2022

Just a convention to make a good-looking contract. :3
Feel free to apply it.


- 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 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
. "$(dirname "$0")/_/"

npx pretty-quick --staged && npm run lint


npm run format
  • DO run lint before commit
npm run lint


Style guide:

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…