Security best practices
Some of the important security best practices, both from an audit as well as an implementation perspective, are listed in this section. They should be applied to smart contracts as and when they become an application:
- Each function within a smart contract should have the following:
- Only the required number of parameters with the most restrictive data type. There should not be extra parameters.
- The return type from a function should again be appropriately constrained with the right data type.
- An argument input validation as the first set of actions or steps within a function.
- Proper exception handling using
requires/revert
functions for input validation andtry-catch
blocks for making external calls to other smart contracts. - The correct and appropriate scope, and visibility assigned. If a function can only be called from a contract, do not mark it as public. Similarly, if a function can only be called from an external request, it should be marked as external...