<!-- canonical: https://0xsimao.com/findings/metazero-ii-custom-require-statements-gas -->

# Custom errors should be used instead of require() statements to save gas

Low/Info · Three Sigma · Omnichain RWA tokenisation · 6th April, 2024

Finding 3S-MZ-N02 of the MetaZero Staking security review.

- Protocol: https://metazero.gg/
- Report: /reports/metazero-ii
- Codebase: https://github.com/0xsimao/stakingContract/tree/dffac73e838a9fbd12bed18e41b9799177bcde7f
- Source: https://cdn.sanity.io/files/qoqld077/production/3e07b0c2806b62578b8031e88c59bc5dbd38de1b.pdf

---

### Description

require() statements spend more gas than custom errors.

### Recommendation

Replace require() statements with custom errors.

### Status

Acknowledged

---

Related findings:

- [Implement Custom Errors Instead of require Statements](https://0xsimao.com/findings/ostium-implement-custom-require-statements): Ostium
- [MapleLoan change the order of require to save on gas.](https://0xsimao.com/findings/maple-finance-iii-change-require-save-gas): Maple Finance
- [Throughout code base: use Solidity native errors implementation instead of string errors.](https://0xsimao.com/findings/maple-finance-iii-solidity-native-implementation-string): Maple Finance
- [In glAVAX, checking that amount > 0 earlier can save some gas](https://0xsimao.com/findings/glacier-avax-checking-earlier-gas): Glacier
