storage-layout
v0.0.1
Published
TypeScript utilities for Solidity's storage layout compiler output
Maintainers
Readme
storage-layout
TypeScript utilities for Solidity's storageLayout. The storage layout is a lesser known compiler output detailing contract variable storage slot locations.
This library allows for inspecting / decoding public or private contract variables of smart contracts written in the Solidity programming language. It infers TypeScript types for autocomplete and strict type checking.
import { decodeStorage, getVariableStorageSlot } from "storage-layout";
const storageLayout = // ...
const slot = getVariableStorageSlot(storageLayout, "totalSupply");
const storage = // ...
const variable = decodeStorage(storageLayout, storage, "totalSupply");
// 10nInstallation
API
getVariableStorageSlot()
decodeStorage()
readContractVariable()
StorageLayout
Where to get storage layouts
Internal documentation
Data types
- value types (
address,uint[n],int[n],bool) bytes/stringstruct- fixed arrays
- dynamic arrays
mapping- user defined value type
TODO(kyle)
- add error for user defined value types
- dynamic array storage slots
- mapping storage slots
- struct field storage slots
- add other helper functions ()
- human readable
- publishing
