Validating your statements
Once the proof has been fetched, we can verify it using a custom contract on Chiado. The contract will use the HashiProver helper library to check the proof against the block header stored on Chiado.
Deploying the Custom Verification Contract on Chiado
Here is a custom contract that deployed on Chiado can be used to read and verify the Transfer event on Sepolia:
Deployment:
In this example, pass to the custom verification contract constructor <ShoyuBashi contract address on Chiado, the ERC20 contract address on Sepolia, from which the Transfer event is emitted, chain ID of the ERC20Contract (Sepolia: 11155111)>
verifyForeignEvent
explanation:
Inputs:
proof
: the HashiAPI retreived proof
Logic:
check that the proof chainID matches the origin chain chainId (Sepolia in this case).
The
verifyForeignEvent
function validates the event proof against the block header stored on Chiado, which was relayed from Sepolia.check that
rlpEncodedEvent
returned fromHashiProver.verifyForeignEvent
matches the expectedRlpEncodedEvent that we passed as the function argument. This is useful to check that the Event infos encoded in the proof just verified actually match the Event we expect.If the proof is valid, the contract emits the
TransferEventVerified
event. You may define your own logic after the proof has been verified.
Submitting the Proof
Once the contract is deployed on Chiado, 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 Sepolia. If the proof is valid, the rplEncodedEvent will be emitted.
References
Last updated