Compiler version must satisfy a semver requirementSOLHINT-W1043No console.log/logInt/logBytesX/logString/etc & No hardhat and forge-std console.sol import statementsSOLHINT-W1007Enforces the use of double or simple quotes as configured for string literals. Values must be 'single' or 'double'SOLHINT-W1017Avoid to use `.call.value()()`SOLHINT-W1036Avoid to use low level callsSOLHINT-W1037Explicitly mark visibility in functionSOLHINT-W1044Explicitly mark all external contracts as trusted or untrustedSOLHINT-W1045Avoid multiple calls of `send` method in single transactionSOLHINT-W1046Fallback function must be simpleSOLHINT-W1047Do not rely on `block.blockhash`. Miners can influence its valueSOLHINT-W1049Use `keccak256` instead of deprecated `sha3`SOLHINT-W1038Use `selfdestruct` instead of deprecated `suicide`SOLHINT-W1039`throw` is deprecated, avoid to use itSOLHINT-W1040Avoid to use tx.originSOLHINT-W1041Check result of `send` callSOLHINT-W1042Line length must be no more than maxlenSOLHINT-W1005Avoid to use inline assembly. It is acceptable only in rare casesSOLHINT-W1048Avoid making time-based decisions in your business logicSOLHINT-W1050Possible reentrancy vulnerabilities. Avoid state changes after transferSOLHINT-W1051Explicitly mark visibility of stateSOLHINT-W1052Function body contains `count` lines but allowed no more than maxlinesSOLHINT-W1004Function order is incorrectSOLHINT-W1032Import statements must be on topSOLHINT-W1033Function has cyclomatic complexity `current` but allowed no more than maxcomplSOLHINT-W1001Forbid or enforce explicit types (like uint256) that have an alias (like uint)SOLHINT-W1003Contract has `some count` states declarations but allowed no more than maxstatesSOLHINT-W1006Code block has zero statements inside. Exceptions applySOLHINT-W1008Import statement includes an entire file instead of selected symbolsSOLHINT-W1009Imported object name is not being used by the contractSOLHINT-W1010Variable `name` is unusedSOLHINT-W1011Enforces the use of ONE Contract per fileSOLHINT-W1012When fallback is not payable you will not be able to receive ethersSOLHINT-W1013Require or revert statement must have a reason string and check that each reason string is at most N characters longSOLHINT-W1014Constructors should use the new constructor keywordSOLHINT-W1015Constant name must be in capitalized SNAKE_CASE. (Does not check IMMUTABLES, use immutable-vars-naming)SOLHINT-W1018Contract, Structs and Enums should be in CamelCaseSOLHINT-W1019Event name must be in CamelCaseSOLHINT-W1020Enforce naming convention on functions for Foundry test casesSOLHINT-W1021Function name must be in mixedCaseSOLHINT-W1022Enforce named parameters for function calls with 4 or more arguments. This rule may have some false positivesSOLHINT-W1023Function param name must be in mixedCaseSOLHINT-W1024Check Immutable variables. Capitalized SNAKE_CASE or mixedCase depending on configurationSOLHINT-W1025Modifier name must be in mixedCaseSOLHINT-W1026Solidity v0.8.18 introduced named parameters on the mappings definitionSOLHINT-W1027Enforce the return values of a function to be namedSOLHINT-W1028Non-external functions and state variables should start with a single underscore. Others, shouldn'tSOLHINT-W1029Variable name must be in mixedCase. (Does not check IMMUTABLES, use immutable-vars-naming)SOLHINT-W1031Check order of elements in file and inside each contract, according to the style guideSOLHINT-W1034Visibility modifier must be first in list of modifiersSOLHINT-W1035Check that all public or external functions are override. This is iseful to make sure that the whole API is extracted in an interfaceSOLHINT-W1016Avoid to use letters 'I', 'l', 'O' as identifiersSOLHINT-W1030Enforces the use of Custom Errors over Require and Revert statementsSOLHINT-W1002
Check order of elements in file and inside each contract, according to the style guideSOLHINT-W1034
Check order of elements in file and inside each contract, according to the style guide.
Bad Practice
- State variable declaration after function
contract MyContract {
function foo() public {}
uint a;
}
- Library after contract
contract MyContract {}
library MyLibrary {}
- Interface after library
library MyLibrary {}
interface MyInterface {}
- Use for after state variable
contract MyContract {
uint public x;
using MyMathLib for uint;
}
- External pure before external view
contract MyContract {
function myExternalFunction() external {}
function myExternalPureFunction() external pure {}
function myExternalViewFunction() external view {}
}
- Public pure before public view
contract MyContract {
function myPublicFunction() public {}
function myPublicPureFunction() public pure {}
function myPublicViewFunction() public view {}
}
- Internal pure before internal view
contract MyContract {
function myInternalFunction() internal {}
function myInternalPureFunction() internal pure {}
function myInternalViewFunction() internal view {}
}
- Private pure before private view
contract MyContract {
function myPrivateFunction() private {}
function myPrivatePureFunction() private pure {}
function myPrivateViewFunction() private view {}
}
Recommended
- All units are in order - ^0.4.0
pragma solidity ^0.4.0;
import "./some/library.sol";
import "./some/other-library.sol";
enum MyEnum {
Foo,
Bar
}
struct MyStruct {
uint x;
uint y;
}
interface IBox {
function getValue() public;
function setValue(uint) public;
}
library MyLibrary {
function add(uint a, uint b, uint c) public returns (uint) {
return a + b + c;
}
}
contract MyContract {
struct InnerStruct {
bool flag;
}
enum InnerEnum {
A, B, C
}
uint public x;
uint public y;
event MyEvent(address a);
constructor () public {}
fallback () external {}
function myExternalFunction() external {}
function myExternalConstantFunction() external constant {}
function myPublicFunction() public {}
function myPublicConstantFunction() public constant {}
function myInternalFunction() internal {}
function myPrivateFunction() private {}
}
- All units are in order - ^0.5.0
pragma solidity ^0.5.0;
import "./some/library.sol";
import "./some/other-library.sol";
enum MyEnum {
Foo,
Bar
}
struct MyStruct {
uint x;
uint y;
}
interface IBox {
function getValue() public;
function setValue(uint) public;
}
library MyLibrary {
function add(uint a, uint b, uint c) public returns (uint) {
return a + b + c;
}
}
contract MyContract {
using MyLibrary for uint;
struct InnerStruct {
bool flag;
}
enum InnerEnum {
A, B, C
}
address payable owner;
uint public x;
uint public y;
event MyEvent(address a);
modifier onlyOwner {
require(
msg.sender == owner,
"Only owner can call this function."
);
_;
}
constructor () public {}
fallback () external {}
function myExternalFunction() external {}
function myExternalViewFunction() external view {}
function myExternalPureFunction() external pure {}
function myPublicFunction() public {}
function myPublicViewFunction() public view {}
function myPublicPureFunction() public pure {}
function myInternalFunction() internal {}
function myInternalViewFunction() internal view {}
function myInternalPureFunction() internal pure {}
function myPrivateFunction() private {}
function myPrivateViewFunction() private view {}
function myPrivatePureFunction() private pure {}
}
- All units are in order - ^0.6.0
pragma solidity ^0.6.0;
import "./some/library.sol";
import "./some/other-library.sol";
enum MyEnum {
Foo,
Bar
}
struct MyStruct {
uint x;
uint y;
}
interface IBox {
function getValue() public;
function setValue(uint) public;
}
library MyLibrary {
function add(uint a, uint b, uint c) public returns (uint) {
return a + b + c;
}
}
contract MyContract {
using MyLibrary for uint;
struct InnerStruct {
bool flag;
}
enum InnerEnum {
A, B, C
}
address payable owner;
uint public x;
uint public y;
event MyEvent(address a);
modifier onlyOwner {
require(
msg.sender == owner,
"Only owner can call this function."
);
_;
}
constructor () public {}
receive() external payable {}
fallback () external {}
function myExternalFunction() external {}
function myExternalViewFunction() external view {}
function myExternalPureFunction() external pure {}
function myPublicFunction() public {}
function myPublicViewFunction() public view {}
function myPublicPureFunction() public pure {}
function myInternalFunction() internal {}
function myInternalViewFunction() internal view {}
function myInternalPureFunction() internal pure {}
function myPrivateFunction() private {}
function myPrivateViewFunction() private view {}
function myPrivatePureFunction() private pure {}
}
Learn more
ordering on Solhint's documentation.