Files
web/apps/base-docs/tutorials/docs/4_hardhat-profiling-size.md
2024-08-14 15:32:42 -04:00

26 KiB

title, slug, description, author, keywords, tags, difficulty, hide_table_of_contents, displayed_sidebar
title slug description author keywords tags difficulty hide_table_of_contents displayed_sidebar
Hardhat: Optimizing the size of smart contracts /hardhat-profiling-size A tutorial that teaches how to optimize the size of your smart contracts using Hardhat. Edson Alcala and Brian Doyle
Smart Contract Sizes
Hardhat Contract Sizer
Base network
Base blockchain
Blockchain
Contract Optimization
Inheritance
External Contracts
Solidity Optimizer
Smart Contract Development
smart contracts
beginner false null

import Video from '../../src/components/VideoPlayer/index.jsx'

In this tutorial, you'll learn how to profile and optimize smart contract sizes with Hardhat and the Hardhat Contract Sizer plugin.


Objectives

By the end of this tutorial you should be able to:

  • Use Hardhat Contract Sizer plugin to profile contract size
  • Describe common strategies for managing the contract size limit
  • Describe the impact that inheritance has on the byte code size limit
  • Describe the impact that external contracts have on the byte code size limit
  • Describe the impact of using libraries has on the byte code size limit
  • Describe the impact of using the Solidity optimizer

Overview

In the world of blockchain and Ethereum, optimizing smart contract sizes is crucial. Smaller contracts consume less gas during deployment and execution, which is translated into gas costs savings for your users. Fortunately, you can use in Hardhat the hardhat-contract-sizer plugin that helps you analyze and optimize the size of your smart contracts.

Setting up the Hardhat Contract Sizer plugin