Solidity Patterns
This chapter talks about Solidity Pattern that allows someone to write secure code. Mainly takeaways from this page, strongly recommend to give it a read and get familiar with it.
Highlight
- Checks Effects Interactions: prevents reentrancy attack
- Secure Ether Transfer:
use
transfer()
rather thansend()
, also prevent the reentrancy attack - Randomness and Oracle
- Proxy Delegate: for contract upgradability
- Tight Variable Packing:
pack variables into a word (32 bytes, i.e.
uint256
) as much as you can to save storage and gas
Other
solcurity also is a checklist on coding decision for economic and security concerns.
useful-solidity-patterns by dragonfly-xyz also have a list on useful solidity patterns.
Solidity Security by Sigma Prime writes the anti-patterns of Solidity.