std-storage
https://book.getfoundry.sh/reference/forge-std/std-storage.html
stdstore
Query functions:
target
: Set the address of the contract (required)sig
: Set the signature of the function to call (required)with_key
: Set the mapping key, if the variable is of typemapping
depth
: Set the index of the struct member, if the variable is of typestruct
Terminator functions:
checked_write
: Set the data to be written to the storage slot(s)find
: Return the slot number
Example 1
playerToCharacter
tracks each player's character's stats.
Let's say we want to set the level of our character to 120.
Example 2
.selector
A function selector is the first four bytes of the calldata that specifies which function to call during a function call
.selector
returns the ABI function selector.
The first four bytes of the call data for a function call specifies the function to be called. It is the first (left, high-order in big-endian) four bytes of the Keccak-256 (SHA-3) hash of the signature of the function. The signature is defined as the canonical expression of the basic prototype without data location specifier, i.e. the function name with the parenthesised list of parameter types. Parameter types are split by a single comma - no spaces are used.
Last updated