Skip to content

Step by step Storage Proofs with Herodotus || Workshop/tutorial showcasing YAB <> Herodotus integration

Notifications You must be signed in to change notification settings

HerodotusDev/yab-herodotus

Repository files navigation

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.

How to follow

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).

Setup

You need these installed:

First make sure you:

  • Copy the .env.example to .env and fill in the values.

    • Get the Herodotus API key from here.
    • You can get the RPC_URLs from Alchemy, Infura or any other provider. (I placed some free urls in the .env.example, they might work or not, you can try them out)
  • Run:

    bun i

0. Obtain Slot from Storage Layout

bun storage-layout

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.

1. Get In-Mapping Slot

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

2. Prove the Slot/s with Herodotus

Note: This step doesn't have a separate run script, please move to the next step.

3. Access Proven Slots

Run the whole flow

bun start

About

Step by step Storage Proofs with Herodotus || Workshop/tutorial showcasing YAB <> Herodotus integration

Resources

Stars

Watchers

Forks