YAB <> Herodotus
This repo serves as a step by step tutorial on how to use storage proofs from start to end. It's showcasing it on the YAB contracts, to be more precise, their transfers
mapping. This is quite an advanced example of a storage proof, as mappings, especially ones with custom bytes32
as key, are quite tricky to work with, however this allows this tutorial to relay more knowledge. Also, this tutorial focuses on accessing the proven data off-chain, an on-chain example will be available soon, however by following this you will probably be able to understand how to do it on-chain easily, the only thing that you have to do differently is the 3rd step, that one will be done on-chain.
This README.md
is a holistic overview of this tutorial, steps Setup & 0 are meant to be followed from this readme, however steps 1, 2 & 3 are described in depth inside the code, follow the hyperlinks to code files, and run scripts at the end to see the results (note that there is no script for step 2, just continue to step 3).
You need these installed:
First make sure you:
-
Copy the
.env.example
to.env
and fill in the values. -
Run:
bun i
Using hardhat-storage-layout
bun storage-layout
Or tool like https://storage.herodotus.dev/ or https://evm.storage/
If you want to get the storage layout for a deployed contract, just grab the address and check it there, but we will continue with the storage layout we got from the previous step.
The YAB slots we are interested in are a mapping. It requires additional steps to get a particular slot.
mapping(bytes32 => struct YABTransfer.TransferInfo)
To test if the slots are correct, run:
bun test get-slots
Note: This step doesn't have a separate run script, please move to the next step.
bun start