<!-- canonical: https://0xsimao.com/findings/metazero-i-mint-gas-caching-counter -->

# genesisMint gas costs can be reduced by caching genesisCounter

Low/Info · Three Sigma · Omnichain RWA tokenisation · 27th January, 2024

Finding 3S-MetaZero-N01 of the MetaZero Omnichain NFTs security review.

- Protocol: https://metazero.gg/
- Report: /reports/metazero-i
- Source: https://cdn.sanity.io/files/qoqld077/production/1b1ab4ff365756fe1d86767f1e06744407570f5a.pdf

---

### Description

The [genesisMint()](https://github.com/threesigmaxyz/metazero-issues-external/blob/master/src/ONFTV2-721C.sol#L76-L80) function could cache genesisCounter while looping:

```solidity
uint256 cachedGenesisCounter = genesisCounter;
for (uint i; i < _to.length; ++i) {
    _mint(_to[i], _ids[i]);
    isGenesis[_ids[i]] = true;
    cachedGenesisCounter++;
}
genesisCounter = cachedGenesisCounter;
```

### Status

Addressed in 6ff3111.
