## Tech Talk Oct 12 '23
[OpenZeppelin Contracts Release V5](https://github.com/OpenZeppelin/openzeppelin-contracts/releases/tag/v5.0.0) --- ## `$WHOAMI` * DeFi developer and Web3.0 Instructor. * Currently, * Building $DINERO * Blockchain Instructor at York University * Previously, * CTO and lead Blockchain Developer at opty.fi * Adjunct Professor at George Brown College --- ## New addition to V5 * Modern best practices and namespace storages * Reduced gas consumption * Simplicity in codebase * Improving AccessManager * Test coverage is ~99% by adding fuzzing --- ## importing OZ V5 ``` # Remix import "https://github.com/OpenZeppelin/openzeppelin-contracts/tree/v5.0.0/contracts" # foundry forge install forge install OpenZeppelin/openzeppelin-contracts@v5.0.0 # Add @openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ in remappings.txt. # hardhat npm install @openzeppelin/contracts@v5.0.0 ``` --- ## ERC20 hooks removal
--- ## Ownable * Ownable now accepts a custom owner argument during construction, and Governor supports voting with bytes-formatted signatures and has Account Abstraction support by implementing ERC-1271. --- ## Removal * Address.isContract * Counters * SafeMath * SignedSafeMath * GovernorCompatibilityBravo * GovernorVotesComp * TokenTimelock (in favor of VestingWallet) * ERC777 * All cross-chain contracts (including AccessControlCrossChain) --- ### Namespaced Storage for better upgrades security(ERC-7201)
Previously, upgradeable contracts used to have a `__gap` variable in storage between inherited contracts in order to reserve space for supporting new variables added between upgrades. --- ### scoping variables by namespace
--- ## Custom Error and dynamic argument
--- ## AccessManager * Make managing access control easier! * Connect contract to an authority for access control * Time-locked governance proposals * Auth Utils Lib ---
--- ## Packing variables in storage
--- ## Account Abstraction * Additional ERC-2771 and ERC-1967 support --- ## Utils libraries * Simplify handling nonces, ECDSA & Time --- ## Tooling update * Contract library integrated to work with OZ defender * Improved Upgrade plugin for hardhat, foundry in pipeline --- ## Gas optmization * Use custom error instead of revert string * Use immutable variable to save use of SLOAD instruction --- ## Recommended Readings * [Openzeppelin Contracts V5 Release Notes](https://github.com/OpenZeppelin/openzeppelin-contracts/releases/tag/v5.0.0) * [OpenZeppelin Contract V5 blog](https://blog.openzeppelin.com/introducing-openzeppelin-contracts-5.0)