How do I find the slot of a private variable?
I know that Foundry has the method
stdstorage.sig(), but that only works for variables with public getters, so private ones are out of scope.
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
Forge provides the
inspect command to get specialized information about a smart contract.
Printing a contract's storage layout is achieved via:
forge inspect <Contract> storage --pretty
<Contract> is the path to the contract's file plus the contract's name, eg
--pretty flag prints the storage layout in a more readable format. Without it, the command outputs the storage layout in json format.