Upgrades method to obtain contract layout storage


Is there a method available in Hardhat Upgrades package that can spit out the current storage layout of a contract in Hardhat?

I know the storage layout is built and stored in the .openzeppelin/* when deploying an upgradeable contract, however, the feature on its own (in example: get-storage-layout ./contracts/MyContract.sol) would be helpful to have a better understanding of your contract's storage layout as you develop it.


The layout for storage is described in the in the language docs

You can get the layout of a contract by running the compiler with the --storage-layout argument: solc --storage-layout contract.sol

1 Like

Did you get it work? Why did I get the following error message?

solc --storage-layout Contract.sol
Warning: 'storage-layout' is not in the list of known options, but still passed to Electron/Chromium.

Well, the arg is there ...

$ solc --help |grep -e "--storage-layout"
  --storage-layout     Slots, offsets and types of the contract's state 

How are you calling solc ?
are you using a Electron/Chromium interface ?

calling it in the command line works

Yes, I called it in the command line but got that error message. Is it possible that you could share a screenshot of a successful run? Thanks.

pragma solidity ^0.8.0;

contract Example {
    address public someAddr;

    constructor () { someAddr = msg.sender; }

still find it odd the mention of Electron/Chromium on the error message, solc has nothing to do with either

1 Like

I think there might be conflict. Many thanks.