How Relayer Work?

by Athena, Co-Funder/CTO

1. Overall Architecture

In the Sealer Network ecosystem, a Relayer is a crucial component that interfaces with specific types of blockchains and forwards inscription messages. Its primary functions include Bitcoin adaptation, inscription transaction monitoring, inscription transaction filtering, and inscription transaction routing. This article mainly discusses the design philosophy of the Relayer from the perspectives of the Relayer's architecture, the inscription transaction process, and the decoupling methods for Bitcoin and Relayer.

To support the switching between different inscription protocols, Relayer has adopted the following layered design:

  1. Inscription Protocol Layer: This layer is responsible for interacting with the inscription protocol, providing a unified interface for higher-level interactions. Due to the diversity of inscription protocols, a plugin mechanism is employed to facilitate the adaptation of these protocols with Relayer, ensuring decoupling and convenient integration.

  2. Interaction Layer: This layer includes specific logic on how to submit ISTP packets and how to listen for inscription transactions on the application chain. Situated at the lower level of Relayer, it comprises execution and listening modules. The interaction layer shields the upper modules from the details of obtaining and submitting inscription transactions from the inscription protocol, offering a more streamlined interface.

  3. Sealer Layer: Acting as the intermediary dispatch layer for message flow in Relayer, this layer processes and routes inscription messages coming from the inscription protocol. The Sealer layer primarily masks the complexities of different inscriptions, uniformly invoking underlying modules.

2. Stateless and Efficiency

Different Relayers handle different inscription protocols, and the inscription protocols also support transportation by multiple Relayers.

For a Relayer to effectively perform its transportation role, the first essential step is to support a stateless mode. In other words, a Relayer doesn't need to store any data; it only needs to synchronize the Bitcoin network and Sealer's block headers upon startup. To facilitate this, the node's Merkle Tree has been upgraded to generate a Merkle subtree for each inscription transaction protocol, enabling Relayers to quickly check whether an inscription transaction has been submitted to the chain.

The second step involves the interaction logic between the Relayer and Sealer nodes, which is common and can be abstracted into the form of Relayer Core. The part of the Relayer that interacts with the inscription protocol is customized and needs to be abstracted into the form of Relayer Plugin.

This approach allows Relayers to achieve plugin-based, stateless, and efficient operation for different inscription protocols.

3. Bitcoin/BRC20 Bridge

The Schnorr aggregate signature scheme is primarily designed for cross-chain solutions of assets with a UTXO (Unspent Transaction Output) model. Since most blockchains using the UTXO model cannot provide Turing-complete smart contracts, the Sealer Network adopts a method of "synchronizing block headers + aggregate signature address custody" for cross-chain digital assets. This method decentralizes the mapping of Bitcoin digital assets. The main process is as follows:

Startup Phase:

Multiple nodes of the relay chain generate a multi-signature address for the application chain. The cross-chain gateway monitors the digital asset balance changes of this multi-signature address. If necessary, relay chain nodes need to synchronize the application chain block headers to maintain the longest chain update.

Bitcoin/BRC20 Cross-Chain Anchoring Process:

  1. Users send transactions to lock their digital assets into the aggregate signature address. The transaction note (via Bitcoin's OP_RETURN) includes the user's Sealer address.

  2. Relayer listens to the cross-chain transaction and submits the application chain transaction text (Tx) and existence proof (Proof) to the node.

  3. After the node network verifies, it maps the corresponding digital assets to the user's Sealer address, completing the cross-chain anchoring operation.

Bitcoin/BRC20 Cross-Chain Unanchoring Process:

  1. Users initiate a digital asset unlock request to the Sealer network, including their Bitcoin address and the amount of digital assets.

  2. The Sealer network freezes the user's mapped assets and triggers a cross-chain unanchoring event.

  3. Upon hearing the Sealer network's cross-chain unanchoring event, Relayer constructs a cross-chain unsigned transaction and submits it to the Sealer Network (if it's BRC20, due to the inscription action, there will be at least two transactions).

  4. After Sealer nodes verify the received unsigned transaction, they perform an aggregate signature.

  5. Relayer, upon noticing that the Sealer network has completed the aggregate signature for the transaction, broadcasts the aggregate transaction to the Bitcoin network.

  6. Users receive an equivalent amount of digital assets from the Bitcoin network.

  7. Relayer submits the transaction text (Tx) and existence proof (Proof) from the Bitcoin network to the Sealer network for verification.

  8. After the Sealer network verifies, it destroys the user's mapped assets, completing the cross-chain unanchoring operation.

More articles

SITP: Sealer Inscription Transfer Protocol

Introduce the key features of the SITP protocol mainly include inscription services and the proof of inscription transactions.

Read more

Why Sealer Network?

Sealer Network is a Bitcoin layer 2 focusing on decentralized indexer services and supports all inscription protocols in the Bitcoin ecosystem.

Read more

Any questions? Looking forward to hearing from you!