Security
https://docs.openzeppelin.com/contracts/4.x/api/security
These contracts aim to cover common security practices
PullPayment
A pattern that can be used to avoid reentrancy attacks
ReentrancyGuard
A modifier that can prevent reentrancy during certain functions
Pausable
A common emergency response mechanism that can pause functionality while a remediation is pending
Constructor
Older versions of Solidity didn't have the
constructor
keywordIt took the function with EXACTLY the same name as the contract and used that as the constructor
So... if you got the name wrong even a little bit, the constructor wouldn't run and become accessible to anyone
Rubixi bug: https://www.youtube.com/watch?v=h4dxwYQQ_b8
Self Destruct
If you send funds then immediately call
selfdestruct()
then the contract you call could try to revert and send the funds back, but it can't since you selfdestructed, so it keeps the funds, but doesn't continue with the code past the revert pointIf you code your contract badly, this could brick the function (e.g. setting a winner after checking the current balance)
Therefore, use a counter that is part of the function, instead of
address(this).balance
so that the code is executed as expected during revert
So instead, use a global balance variable to keep track of the funds, not just the contract balance
Last updated