Open iFrostizz opened 1 year ago
I'm happy to take this one
Did you take it? :D
Nope @spaceh3ad !
Do we currently have a way to do that from cast
?
Otherwise what choice do we have for private
or internal
immutable to get them onchain?
@Ethnical you can use cast storage
or load storage slot with vm.load()
@spaceh3ad How this is possible since this is not inside the storage as this is inside the bytecode directly?
+1 to this feature!
Component
Forge
Describe the feature you would like
It is currently impossible to read private immutable variables in Foundry because of how they work. Immutables are, similarly to constants, inlined in the bytecode directly and
PUSH
ed where they are needed. The issue is that immutables are, as opposed to constants, not known before the contract construction. This makes them, even more tricky to read if private. Because that would imply reading the code and parsing what's of interest, making it not scalable as the code change, or optimizations.Example:
My proposition would be to add a cheatcode to read immutables, and constants directly from the code called
codeLoad
(very open to propositions). It would work by using the solc output, probably the bytecode to source code mapping in order to generate bindings for the immutables and constants that are defined in the contract and expose them through the cheatcode.Additional context
No response