Key Contracts

Hashi relies on a set of core smart contracts to enable secure cross-chain communication, storage verification, and message dispatching. These contracts form the backbone of Hashi's decentralized system, ensuring that data and messages relayed across different blockchains are validated, secure, and cryptographically sound.

In this section, we’ll introduce the key contracts that you will interact with when using Hashi, detailing their primary functions and how they work together to facilitate cross-chain operations.

1. Yaho (Message Dispatch Contract)

The Yaho contract is responsible for dispatching messages from one blockchain to another. It manages the sending of cross-chain messages by interacting with Hashi’s oracle system, ensuring that messages are transmitted and validated before they are delivered to the destination chain.

  • Primary Function: Dispatches messages across chains.

  • Usage: Interacts with oracles to relay messages from the source chain (e.g., Sepolia) to the destination chain (e.g., Gnosis Chain).

  • Key Methods:

    • dispatchMessageToAdapters(uint256 targetChainId, uint256 threshold, address targetAddress, bytes memory data, address[] memory reporters, address[] memory adapters)

      • Dispatches a message with specified reporters and adapters to the target chain.

2. Yaru (Message Validation Contract)

The Yaru contract handles the receiving and validation of cross-chain messages. It works on the destination chain to ensure that messages sent by the Yaho contract are legitimate and validated by Hashi’s oracles before triggering any actions.

  • Primary Function: Validates cross-chain messages and triggers callbacks on the destination chain.

  • Usage: Used on the receiving side to validate messages dispatched by Yaho.

  • Key Methods:

    • onMessage(uint256 messageId, uint256 chainId, address sender, uint256 threshold, address[] memory adapters, bytes memory data)

      • Validates a message and triggers the corresponding action on the destination contract.

3. Header Storage

The Header Storage contract stores block headers from a source chain, which are then used to verify storage proofs or validate the state on the destination chain. Block headers are essential to cross-chain validation, as they contain the cryptographic data needed to prove the state of a contract on another chain.

  • Primary Function: Stores block headers for cross-chain state verification.

  • Usage: Relays block headers from the source chain (e.g., Optimism) to the destination chain (e.g., Gnosis Chain).

  • Key Methods:

    • storeBlockHeader(bytes memory headerData)

      • Stores a new block header from the source chain.

4. HashiProver

HashiProver is a helper contract used to verify cross-chain storage proofs and account states. It works by comparing the storage proofs provided with the block headers stored in the Header Storage contract.

  • Primary Function: Verifies storage proofs and account states across chains.

  • Usage: Used when you need to verify a foreign contract’s state (e.g., checking the USDC total supply on Optimism from Gnosis Chain).

  • Key Methods:

    • verifyForeignStorage(AccountAndStorageProof calldata proof)

      • Verifies a storage proof against the latest block header stored in the Header Storage contract.

5. ShoyuBashi (Oracle Manager Contract)

ShoyuBashi manages the oracles that relay messages and block headers between chains. This contract is responsible for coordinating the oracle system and ensuring that multiple oracles reach consensus before a message or block header is considered valid.

  • Primary Function: Manages oracles and relays messages or block headers.

  • Usage: Ensures secure and validated message passing between chains by coordinating oracle responses.

  • Key Methods:

    • relayBlockHeader(uint256 chainId, bytes memory headerData)

      • Relays block headers between chains using oracles.

    • dispatchMessage(uint256 chainId, address targetAddress, bytes memory data)

      • Dispatches messages through oracles for cross-chain validation.


Understanding Their Roles

Each of these contracts plays a crucial role in Hashi’s cross-chain framework:

  • Yaho dispatches messages, while Yaru validates them.

  • Header Storage stores block headers, which are used by HashiProver to verify state proofs.

  • ShoyuBashi coordinates oracles to securely relay data between chains.

These contracts work in harmony to ensure that messages and state changes across blockchains are cryptographically secure and validated by multiple independent oracles, ensuring a trustless cross-chain environment.

Last updated