Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/itsnickbarry/hardhat-contract-sizer
Calculate Ethereum contract sizes with Hardhat 📐
https://github.com/itsnickbarry/hardhat-contract-sizer
abi blockchain buidler bytecode ethereum hardhat smart-contracts solc solidity wow
Last synced: 6 days ago
JSON representation
Calculate Ethereum contract sizes with Hardhat 📐
- Host: GitHub
- URL: https://github.com/itsnickbarry/hardhat-contract-sizer
- Owner: ItsNickBarry
- License: mit
- Created: 2020-08-23T21:46:17.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-30T20:35:19.000Z (4 months ago)
- Last Synced: 2024-11-06T15:54:40.464Z (7 days ago)
- Topics: abi, blockchain, buidler, bytecode, ethereum, hardhat, smart-contracts, solc, solidity, wow
- Language: TypeScript
- Homepage:
- Size: 143 KB
- Stars: 75
- Watchers: 4
- Forks: 17
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Hardhat Contract Sizer
Output Solidity contract sizes with Hardhat.
> Versions of this plugin prior to `2.0.0` were released as `buidler-contract-sizer`.
## Installation
```bash
npm install --save-dev hardhat-contract-sizer
# or
yarn add --dev hardhat-contract-sizer
```## Usage
Load plugin in Hardhat config:
```javascript
require('hardhat-contract-sizer');
```Add configuration under the `contractSizer` key:
| option | description | default |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------- | ------- |
| `alphaSort` | whether to sort results table alphabetically (default sort is by contract size) | `false` |
| `runOnCompile` | whether to output contract sizes automatically after compilation | `false` |
| `disambiguatePaths` | whether to output the full path to the compilation artifact (relative to the Hardhat root directory) | `false` |
| `strict` | whether to throw an error if any contracts exceed the size limit (may cause compatibility issues with `solidity-coverage`) | `false` |
| `only` | `Array` of `String` matchers used to select included contracts, defaults to all contracts if `length` is 0 | `[]` |
| `except` | `Array` of `String` matchers used to exclude contracts | `[]` |
| `outputFile` | file path to write contract size report | `null` |
| `unit` | unit of measurement for the size of contracts, which can be expressed in 'B' (bytes), 'kB' (kilobytes) or 'KiB' (kibibytes) | `KiB` |```javascript
contractSizer: {
alphaSort: true,
disambiguatePaths: false,
runOnCompile: true,
strict: true,
only: [':ERC20$'],
}
```Run the included Hardhat task to output compiled contract sizes:
```bash
npx hardhat size-contracts
# or
yarn run hardhat size-contracts
```By default, the hardhat `compile` task is run before sizing contracts. This behavior can be disabled with the `--no-compile` flag:
```bash
npx hardhat size-contracts --no-compile
# or
yarn run hardhat size-contracts --no-compile
```## Development
Install dependencies via Yarn:
```bash
yarn install
```Setup Husky to format code on commit:
```bash
yarn prepare
```