The unique security environment of Ethereum smart contracts and its component Solidity code demands a special set of best practices. One of these best practices is known as the CEI pattern, standing for Checks, Effects, and Interactions. This allows us to structure the order of our Solidity logic in a sensible and consistent way, and to minimize exploits and security risks. Firstly all checks and validations are performed. If any check fails, the function should revert at that point using one of Solidity's modifiers and errors. Next, effects are computed. This refers to updating any internal state in the contract and changing variables. This is done after the checks to insure that variables are only effected in valid ways. Lastly are the interactions. This is where funds are transferred and external contracts are called. By placing the interactions last it forces us to consider the potential impact on the contract's state before interacting with external entities, reducing the risk of reentrancy attacks and enhancing security.
Subscribe to:
Post Comments (Atom)
190: Sablier
The CodeHawks platform has an upcoming audit on the Sablier protocol, so I decided to read through the docs and familiarize myself with the...
-
The CodeHawks platform has an upcoming audit on the Sablier protocol, so I decided to read through the docs and familiarize myself with the...
-
The ZKasino project recently exit scammed over 33 million dollars worth of Ethereum. he recent debacle surrounding ZKasino offers valuable...
-
In addition to its native SDK, Hedera also supports smart contracts in a platform compatible with the Ethereum Virtual Machine. This allows ...
No comments:
Post a Comment