You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.
Generate a proof-of-inclusion of a state stored on Tezos
import{Tezos}from'ibcf-sdk';import{TezosToolkit}from'@taquito/taquito';constTEZOS_RPC='https://rpc.ghostnet.teztnets.xyz';constSTATE_AGGREGATOR_CONTRACT='KT1Aqdz8opKsfADxmF2vf6NMoYwgamL5R4KT';consttezosSdk=newTezosToolkit(TEZOS_RPC);conststateAggregator=newTezos.Contracts.StateAggregator.Contract(tezosSdk,STATE_AGGREGATOR_CONTRACT);constSTATE_ORIGIN='KT1AfcN12T2d43XtJLbahmpDr13xda4Zedxx';constSTATE_KEY='0x01';constSNAPSHOT_LEVEL='1805119';stateAggregator.getProof(STATE_ORIGIN,// OriginSTATE_KEY,// State keySNAPSHOT_LEVEL,// Block level where the snapshot was taken).then(console.log);
Generate a proof-of-inclusion of a state stored on EVM
import{Ethereum}from'ibcf-sdk';import{ethers}from'ethers';constETHEREUM_RPC='https://goerli.infura.io/v3/75829a5785c844bc9c9e6e891130ee6f';constETHEREUM_DAPP='0x10758d99D642428fd6A8B62A149aB2d1ade20C24';constBLOCK_NUMBER=8332856;constprovider=newethers.providers.JsonRpcProvider(ETHEREUM_RPC);constproofGenerator=newEthereum.ProofGenerator(provider);// EVM storage slot indexes (Each slot index is identified by 32 bytes)// - slot 0 ...// - slot 1 ...// - slot 2 ...// - slot 3 ...// - slot 4 ...// - slot 5 -> mapping(uint => bytes) destination_registry;// - slot 6 -> mapping(uint => uint) amount_registry;constdestinationRegistryIndex='5'.padStart(64,'0');constamountRegistryIndex='6'.padStart(64,'0');// Key RLP encodedconstkeyRLP='0x01';// Storage slots// - Each mapping slot is the result of keccak256(<rlp_key> + <slot_index>)constdestinationSlot=ethers.utils.keccak256(keyRLP+destinationRegistryIndex);constamountSlot=ethers.utils.keccak256(keyRLP+amountRegistryIndex);proofGenerator.generateStorageProof(ETHEREUM_DAPP,[destinationSlot,amountSlot],BLOCK_NUMBER).then(console.log);