Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gas estimation of mint function compared to ERC721A and gas report configuration #8

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
src = 'src'
out = 'out'
libs = ['lib']
gas_reports = ["ERC721ACHMock"]

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
41 changes: 41 additions & 0 deletions test/ERC721ACH.t.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;


import "forge-std/console.sol";
import {Vm} from "forge-std/Vm.sol";
import {DSTest} from "ds-test/test.sol";
import {ERC721ACHMock} from "./utils/ERC721ACHMock.sol";
Expand Down Expand Up @@ -144,4 +146,43 @@ contract ERC721ACHTest is DSTest {
address(erc721Mock.isApprovedForAllHook())
);
}

function test_gasEstimateForSingleMint() public {
address buyer = address(0x1111);
console.logString(
"=====================gas estimation for minting single NFT=========================="
);
uint originGasLeft;
uint gasDelta;
originGasLeft = gasleft();
erc721Mock.mint(buyer, 1);
gasDelta = originGasLeft - gasleft() - 100;
console.log("gasDelta: %d", gasDelta);
}

function test_gasEstimateForMint2NFTs() public {
address buyer = address(0x1111);
console.logString(
"=====================gas estimation for minting 2 NFT=========================="
);
uint originGasLeft;
uint gasDelta;
originGasLeft = gasleft();
erc721Mock.mint(buyer, 2);
gasDelta = originGasLeft - gasleft() - 100;
console.log("gasDelta: %d", gasDelta);
}

function test_gasEstimateForMint3NFTs() public {
address buyer = address(0x1111);
console.logString(
"=====================gas estimation for minting 3 NFT=========================="
);
uint originGasLeft;
uint gasDelta;
originGasLeft = gasleft();
erc721Mock.mint(buyer, 3);
gasDelta = originGasLeft - gasleft() - 100;
console.log("gasDelta: %d", gasDelta);
}
}