Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Calculate Ethereum contract sizes with Hardhat 📐

License

NotificationsYou must be signed in to change notification settings

solidstate-network/hardhat-contract-sizer

Repository files navigation

Output Solidity contract sizes with Hardhat.

Versions of this plugin prior to2.0.0 were released asbuidler-contract-sizer.

Installation

npm install --save-dev hardhat-contract-sizer# oryarn add --dev hardhat-contract-sizer

Usage

Load plugin in Hardhat config:

require('hardhat-contract-sizer');

Add configuration under thecontractSizer key:

optiondescriptiondefault
alphaSortwhether to sort results table alphabetically (default sort is by contract size)false
runOnCompilewhether to output contract sizes automatically after compilationfalse
disambiguatePathswhether to output the full path to the compilation artifact (relative to the Hardhat root directory)false
strictwhether to throw an error if any contracts exceed the size limit (may cause compatibility issues withsolidity-coverage)false
onlyArray ofString matchers used to select included contracts, defaults to all contracts iflength is 0[]
exceptArray ofString matchers used to exclude contracts[]
outputFilefile path to write contract size reportnull
unitunit of measurement for the size of contracts, which can be expressed in 'B' (bytes), 'kB' (kilobytes) or 'KiB' (kibibytes)KiB
contractSizer:{alphaSort:true,disambiguatePaths:false,runOnCompile:true,strict:true,only:[':ERC20$'],}

Run the included Hardhat task to output compiled contract sizes:

npx hardhat size-contracts# oryarn run hardhat size-contracts

By default, the hardhatcompile task is run before sizing contracts. This behavior can be disabled with the--no-compile flag:

npx hardhat size-contracts --no-compile# oryarn run hardhat size-contracts --no-compile

Development

Install dependencies via Yarn:

yarn install

Setup Husky to format code on commit:

yarn prepare

About

Calculate Ethereum contract sizes with Hardhat 📐

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors7


[8]ページ先頭

©2009-2025 Movatter.jp