This library enable you to generate and verify ETH merkle proofs, based on given trusted blockHash.
There exits three type of proofs:
HeaderProof
which enable you to proof that givenblock header
consist of given values, this is trival but enable later proofsAccounProof
which enable you to proof that givenaddress
and atblockNumber
=> has some value ofnonce,balance,storageHash,codeHash
StorageSlotProof
which enable you to proof that givenaddress
and atmemorySlot
and atblockNumber
=> has somevalue
This enable you to verify on-chain and off-chain:
- ETH balance
- ERC20 balance
- arbitraty slot of storage in smart contract
- and others
Note: When veirifing proofs we also retrive state which is verifed. So we don't have to explicite pass state which is being verified.
- Generate proofs, which then can be verified on-chain or off-chain
- Depends on connection to rpc node
- Verify proofs off-chain (web or nodejs)
- Pure, but requires trusted
BlockHash
- In this example it is used to proof that some implementation behind proxy has been modified.
- I strictly assume that proxy is openzeppelin https://docs.openzeppelin.com/upgrades-plugins/1.x/proxies Run:
- Set up
- install truffle
npm install -g truffle
- run truffle network
truffle develop
- install truffle
- Run:
yarn install && yarn buld && yarn demo --network truffle
- What is happenning?
- Deploy contract behid upgradable proxy.
- Verify version using
StorageSlotProof
=> detect no change - Upgrade smart contract
- Verify version using
StorageSlotProof
=> detect change
- Note: you can also run demo on goerli network
- just set up envs:
GOERLI_PRIVAT_KEY
- private key on goerli testnet, be sure to feed it with some ETH.ALCHEMY_GOERLI_API_KEY
- api key to alchemy node
- And run
yarn install && yarn buld && yarn demo --network goerli
- just set up envs:
- talk about use cases: https://www.youtube.com/watch?v=ysW-Bq05pJQ&ab_channel=LinkTime
- another talk: https://www.youtube.com/watch?app=desktop&v=ZHNrAXf3RDE&ab_channel=EthereumFoundation
- set of great articles which deep dive in state proofs (thread on the end of article): https://medium.com/@chiqing/verify-usdc-balance-and-nft-meta-data-with-proof-3b4d065ae923
- write
verifyFullAccountProof
andverifyFullStorageSlotProof
- test-data
- solidity-verifier
- js doc
- cairo-verifier?