https://github.com/solidstate-network/hardhat-storage-layout-inspector
Inspect and compare Solidity smart contract storage layouts 🔍
https://github.com/solidstate-network/hardhat-storage-layout-inspector
Last synced: 9 months ago
JSON representation
Inspect and compare Solidity smart contract storage layouts 🔍
- Host: GitHub
- URL: https://github.com/solidstate-network/hardhat-storage-layout-inspector
- Owner: solidstate-network
- License: mit
- Created: 2021-08-30T04:18:34.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-06-08T19:27:38.000Z (10 months ago)
- Last Synced: 2025-06-08T20:29:03.135Z (10 months ago)
- Language: TypeScript
- Size: 506 KB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Hardhat Storage Layout Diff
Inspect and compare Solidity smart contract storage layouts.
## Installation
```bash
npm install --save-dev hardhat-storage-layout-diff
# or
yarn add --dev hardhat-storage-layout-diff
```
## Usage
Load plugin in Hardhat config:
```javascript
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:
```bash
npx hardhat export-storage-layout
# or
yarn run hardhat export-storage-layout
```
Compare two contracts:
```bash
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:
```bash
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:
```bash
yarn install
```
Setup Husky to format code on commit:
```bash
yarn prepare
```