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.
Thanks!
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 communityHow 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.
Thanks!
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
Note that <Contract>
is the path to the contract's file plus the contract's name, eg src/Counter.sol:Counter
.
The --pretty
flag prints the storage layout in a more readable format. Without it, the command outputs the storage layout in json format.
inspect
command? Don't see the flag for it in the docs
cast etherscan-source <address> --chain <chainId>
. See here for more info.
Nov 13 at 10:51