# 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**:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { HashiProver } from "./HashiProver.sol";

contract MockERC20Prover {

    event TransferEventVerified(uint256 indexed chainID, bytes rlpEncodedEvent);

    HashiProver public hashiProver;
    address public erc20Contract;
    uint256 public chainID;

    constructor(address shoyuBashi_, address erc20Contract_, uint256 chainID_) {
        hashiProver = HashiProver(shoyuBashi_);
        erc20Contract = erc20Contract_;
        chainID = chainID_;
    }

    function verifyTransferEvent(HashiProver.ReceiptProof calldata proof, bytes memory expectedRlpEncodedEvent) external {
        require(proof.chainId == chainID, "Invalid chain id"); 

        bytes memory rlpEncodedEvent = hashiProver.verifyForeignEvent(proof);

        require(keccak256(rlpEncodedEvent) == keccak256(expectedRlpEncodedEvent), "invalid event");
        emit TransferEventVerified(proof.chainId , rlpEncodedEvent);

        // TODO: Define custom logic here

    }
}
```

#### Deployment:

* *HashiProver & ShoyuBashi* are already deployed on a [list of networks](/hashi/deployments/blockchains.md#shoyubashi-and-hashi-prover) 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 \<S*hoyuBashi* 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:

* &#x20;`expectedRlpEncodedEvent` : an bytes encoded format with the Event information: check out the [helper script from Hashi-template](https://github.com/crosschain-alliance/hashi-template/blob/main/offchain/script/rlp-encode.js) in order to generate it starting from the Event topics and data.
* `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 from `HashiProver.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.

Check `verifyForeignEvent` implementation [here](https://github.com/gnosis/hashi/blob/main/packages/evm/contracts/prover/HashiProverLib.sol#L39).

**Submitting the Proof**

Once the contract is deployed on **Chiado**, you can submit the proof fetched from the API using the following command:

```solidity
// Example of submitting the proof in Solidity (or via web3 call)
HashiProver.ReceiptProof memory proof = { /* fetched proof from curl command */ };
MockERC20Prover.verifyTransferEvent(proof, expectedRlpEncodedEvent);
```

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

1. [RLP encode event helper script](https://github.com/crosschain-alliance/hashi-template/blob/main/offchain/script/rlp-encode.js)
2. [MockERC20Prover contract](https://github.com/crosschain-alliance/hashi-template/blob/main/hardhat/contracts/stateVerifying/MockERC20Prover.sol)
3. [HashiProver contract](https://github.com/crosschain-alliance/hashi-template/blob/main/hardhat/contracts/stateVerifying/HashiProver.sol)
4. [ShoyuBashi contract](https://github.com/gnosis/hashi/blob/main/packages/evm/contracts/ownable/ShoyuBashi.sol)
5. [MockERC20Prover contract address on Chiado](https://gnosis-chiado.blockscout.com/address/0x7D5C9C15bc2bD2eDcE54BC8c480A94d02666B514)
6. [HashiProver & ShoyuBashi addresses ](/hashi/deployments/blockchains.md#shoyubashi-and-hashi-prover)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://crosschain-alliance.gitbook.io/hashi/getting-started/quick-start/verifying-foreign-event/validating-your-statements.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
