Skip to content

Instantly share code, notes, and snippets.

@cygaar
Last active August 3, 2022 12:40
Show Gist options
  • Save cygaar/6aad3ab2f01a5c8b82d172e526704977 to your computer and use it in GitHub Desktop.
Save cygaar/6aad3ab2f01a5c8b82d172e526704977 to your computer and use it in GitHub Desktop.
ERC721A Optimized Mints
const { deployContract } = require('./helpers.js');
describe.only('ERC721A Gas Usage', function () {
beforeEach(async function () {
const [owner] = await ethers.getSigners();
this.owner = owner;
});
it('deployNormal', async function () {
for (let i = 0; i < 10; i++) {
await deployContract('SampleProject', [this.owner.address]);
}
});
it('deployERC2309', async function () {
for (let i = 0; i < 10; i++) {
await deployContract('SampleProject2309', [this.owner.address]);
}
});
});
·------------------------|---------------------------|-------------|-----------------------------·
| Solc version: 0.8.11 · Optimizer enabled: true · Runs: 800 · Block limit: 30000000 gas │
·························|···························|·············|······························
| Methods │
··············|··········|·············|·············|·············|···············|··············
| Contract · Method · Min · Max · Avg · # calls · usd (avg) │
··············|··········|·············|·············|·············|···············|··············
| Deployments · · % of limit · │
·························|·············|·············|·············|···············|··············
| SampleProject · - · - · 1709572 · 5.7 % · - │
·························|·············|·············|·············|···············|··············
| SampleProject2309 · - · - · 1515973 · 5.1 % · - │
·------------------------|-------------|-------------|-------------|---------------|-------------·
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import './ERC721A.sol';
contract SampleProject is ERC721A {
constructor(address to) ERC721A('SampleProject', 'SAMPLE') {
_mint(to, 100);
for (uint256 i; i < 20; ++i) {
_initializeOwnershipAt(i * 5);
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import './ERC721A.sol';
contract SampleProject2309 is ERC721A {
constructor(address to) ERC721A('SampleProject', 'SAMPLE') {
_mintERC2309(to, 100);
for (uint256 i; i < 20; ++i) {
_initializeOwnershipAt(i * 5);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment