Skip to content

solidstate-network/hardhat-storage-layout-diff

Repository files navigation

Hardhat Storage Layout Diff

Inspect and compare Solidity smart contract storage layouts.

Installation

npm install --save-dev hardhat-storage-layout-diff
# or
yarn add --dev hardhat-storage-layout-diff

Usage

Load plugin in Hardhat config:

require('hardhat-storage-layout-diff');

Add configuration under the storageLayoutDiff key:

option description default
path path to HTML export directory (relative to Hardhat root) './storage_layout'
clear whether to delete old output in path on output generation false
flat whether to flatten output directory (may cause name collisions) false
only Array of String matchers used to select included contracts, defaults to all contracts if length is 0 ['^contracts/'] (dependent on Hardhat paths configuration)
except Array of String matchers used to exclude contracts []
spacing number of spaces per indentation level of formatted output 2

Export storage layouts:

npx hardhat export-storage-layout
# or
yarn run hardhat export-storage-layout

Compare two contracts:

npx hardhat diff-storage-layout [CONTRACT_A_FULLY_QUALIFIED_NAME] [CONTRACT_B_FULLY_QUALIFIED_NAME]
# or
yarn run hardhat diff-storage-layout [CONTRACT_A_FULLY_QUALIFIED_NAME] [CONTRACT_B_FULLY_QUALIFIED_NAME]

Include the optional --a-ref and/or --b-ref arguments to specify the git reference where contracts a and b are defined, respectively.

Compare a contract to an exported JSON layout:

npx hardhat storage-layout-check --source [PATH_TO_LAYOUT_JSON] --b [CONTRACT_B_FULLY_QUALIFIED_NAME]
# or
yarn run hardhat storage-layout-check --source [PATH_TO_LAYOUT_JSON] --b [CONTRACT_B_FULLY_QUALIFIED_NAME]

Development

Install dependencies via Yarn:

yarn install

Setup Husky to format code on commit:

yarn prepare

About

Inspect and compare Solidity smart contract storage layouts 🔍

Resources

License

Stars

Watchers

Forks

Packages

No packages published