Getting Started with Gas Profiling
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
contract Inventory {
address public manager;
uint256 public totalProducts;
struct Product {
uint256 id;
string description;
uint256 price;
}
mapping(uint256 => Product) public products;
constructor() {
manager = msg.sender;
}
function addProduct(string memory description, uint256 price) external {
require(msg.sender == manager, "invalid manager");
totalProducts++;
products[totalProducts] = Product(
totalProducts,
description,
price
);
}
}

PreviousConfiguring the Hardhat Gas Reporter PluginNextTypical Approaches to Reduce Contract Size and Gas Costs
Last updated