Validating your statements
Once the proof has been fetched, we can now verify it using a custom contract on Gnosis Chain. The contract will use the HashiProver helper library to check the proof against the block header stored on Gnosis Chain.
Deploying the custom Verification Contract on Gnosis Chain
Here is a contract that deployed on Gnosis Chain can be used to read and verify the USDC total supply on Optimism:
Deployment:
HashiProver & ShoyuBashi are already deployed on a list of networks that can be called from the custom verification contract (this contract). In order to configure a custom oracle set for it is possible to deploy a new ShoyuBashi contract, inherit HashiProver contract and configure your oracle set in the ShoyuBashi contract.
In this example, pass to the custom verification contract constructor <ShoyuBashi contract address on Gnosis Chain>
readTotalSupply
explanation:
Inputs:
proof
: the HashiAPI retreived storage proof.
Logic:
check that the proof chainID matches the origin chain chainID (Optimism in this case).
check that the USDC contract address.
check that storage key match the expected value.
This contract uses HashiProver to verify on Gnosis Chain the storage proof coming from Optimism fetched earlier.
It checks that the proof is from Optimism (chain ID 10), and that the USDC contract address and storage key match the expected values.
The
verifyForeignStorage
function validates the proof against the block header stored on Gnosis Chain, which was relayed from Optimism.If the proof is valid, the contract emits the total supply of USDC on Optimism.
Check verifyForeignStorage
implementation here.
Submitting the Proof
Once the contract is deployed on Gnosis Chain, you can submit the proof fetched from the API using the following command:
This will trigger the contract to verify the proof using the block header stored in Hashi from Optimism. If the proof is valid, the total supply of USDC will be emitted.
Last updated