hashi
  • Welcome
  • Introduction
    • What is Hashi?
    • Why Hashi?
    • Key Features
    • The SSN
  • Getting Started
    • How Hashi Works
    • Quick Start
      • Verifying foreign event
        • Setting the scene
        • Getting the Event Proof
        • Validating your statements
      • Reading foreign state
        • Setting the scene
        • Getting the Storage Proof
        • Validating your statements
      • Pushing a message
        • Writing your message sending contract
        • Implementing your callback
        • Waiting for the cross-chain execution
  • Core Concepts
    • Block Header Relaying
    • Message Dispatching
    • Oracles
    • Additive Security Model
  • Deployments
    • Blockchains
    • Oracles
  • Smart Contracts
    • Key Contracts
    • HashiProver API
  • TOOLS
    • SP1 storage proof verifier
    • Solana integration
  • APPS / INTEGRATIONS
    • Safe Crosschain
    • Aragon UCG
    • Openfort Chain Abstraction
  • META
    • Developer resources
    • Audits
    • Explorer
    • Community
Powered by GitBook
On this page
Export as PDF
  1. Getting Started
  2. Quick Start
  3. Reading foreign state

Getting the Storage Proof

First we need to fetch the storage proof from Optimism using the block number of a Optimism block which header that has already been propagated to Hashi. This block number ensures that Hashi can verify the proof against the just mentioned block header propagated to Gnosis Chain.

Fetching the Proof

Use the following curl command or javascript script to fetch the account and storage proof for the USDC total supply on Optimism:

curl --location --request POST 'https://jsonrpc.hashi-explorer.xyz/v1' \
--header 'Content-Type: application/json' \
--data-raw '{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "hashi_getAccountAndStorageProof",
  "params": {
      "chainId": 10,
      "address": "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
      "storageKeys": ["0x00000000000000000000000000000000000000000000000000000000000000b"],
      "blockNumber": 126086800
  }
}'
import axios from "axios";

const main = async () => {

  // fetch storage proof from Hashi Prover
  console.log("Fetching storage proof from Hashi prover...");
  const result = await axios.post(
    "http://jsonrpc.hashi-explorer.xyz:3000/v1",
    {
      jsonrpc: "2.0",
      method: "hashi_getAccountAndStorageProof",
      params: {
          chainId: 10,
          address: "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
          storageKeys: ["0x00000000000000000000000000000000000000000000000000000000000000b"],
          blockNumber: 126086800
      },
      id: 1,
    },
    {
      headers: {
        "Content-Type": "application/json",
      },
    }
  );
  console.log("Storage proof result", result.data.result.proof);
};

main();
  • chainId: 10 (Optimism).

  • address: The address of the USDC contract on Optimism: 0x0b2c639c533813f4aa9d7837caf62653d097ff85.

  • storageKeys: The storage key for the USDC total supply: 0xb.

  • blockNumber: The block number on Optimism, 126086800, which must have already been propagated to Gnosis Chain via Hashi for the proof to be valid.

This curl command returns the account and storage proof for the USDC total supply, which will be used for verification on Gnosis Chain.

Use the SP1 storage proof generator

RUST_LOG=info cargo run --release -- --execute \
    --rpc-url https://mainnet.infura.io/v3/YOUR-PROJECT-ID \
    --reference-block-number 0x7B60EA3 \
    --proof-block-number 0x783EE90 \
    --account 0x0b2c639c533813f4aa9d7837caf62653d097ff85 \
    --storage-key 0x000000000000000000000000000000000000000000000000000000000000000b
PreviousSetting the sceneNextValidating your statements

Last updated 5 months ago

Hashi support .

SP1 zkVM to generate storage proofs