Replies: 1 comment 1 reply
-
I use code below to calculate the const abiCoder = new ethers.utils.AbiCoder()
const secondElementLocation = ethers.utils.keccak256(
ethers.utils.concat([
abiCoder.encode(["uint256"], ["0"]),
"0x0000000000000000000000000000000000000000000000000000000000000003",
])
)
const mapElement = await ethers.provider.getStorageAt(
funWithStorage.address,
secondElementLocation
)
log(`Location ${secondElementLocation}: ${mapElement}`) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This question is about finding the location and data of the mappings.
The FunWithStorage.sol comment states a mapping's location can be found using the storage location of the mapping and the value of the key.
Given the above, then
p = 3 because myMap is the fourth state variable declared in the contract.
k = 0 because myMapp[0].
Is the below the correct implementation of the formula in the Solidity comment? Here's the ethers.utils.keccak256 documentation.
No, I have not been able to get the 0x1 representing the true stored at myMap[0]. Please advise.
Beta Was this translation helpful? Give feedback.
All reactions