A Deep Dive into Cross-chain Smart Contract Execution Calls | Analog Insights

  • A Deep Dive into Cross-chain Smart Contract Execution Calls
  • A quick glimpse of Analog and its vision for a multi-chain world
  • Anatomy of Analog’s cross-chain smart contract execution calls
  • High-level architecture of the GMP protocol
  • A deep dive into the cross-chain contract execution calls
  • Conclusion
  • Embark on the cross-chain journey with Analog
Linkedintwitter
TABLE OF CONTENTS

In this second and final part of our blog series, we delve into the details of cross-chain smart contract execution calls that leverage the Analog Network. Part one of this series looked into the need for cross-chain smart contract execution calls, benefits, and some potential use cases for cross-chain smart contract execution calls in a multi-chain world. You can read more about this post here.

A quick glimpse of Analog and its vision for a multi-chain world

Analog Network is a sovereign blockchain ecosystem that provides the building blocks for a truly interoperable Web3 environment. At the core of the Analog Network is the Timechain — a blockchain system — that you can leverage to connect to anything in the Web3 space.

The Timechain is currently built on top of a Nominated Proof-of-Stake (NPoS) consensus algorithm that will later transition to a fairer and more decentralized Proof-of-Time (PoT) protocol. Besides the NPoS consensus, Analog Network validators must participate in multi-party computation (MPC) processes, i.e., threshold signature schemes (TSS), to co-authorize cross-chain requests. The Timechain collectively holds the TSS keys for any authenticated interaction with the external chain.

Through NPoS consensus protocol and TSS mechanisms, the Timechain serves as a core ledger for all activities related to generalized message passing, such as:

  • Witnessing consensus on supported chains

  • Broadcasting consensus to the Timechain and target chains

  • Validator rewards and slashing mechanisms

  • Gas fee handling

To learn more about the overall network architecture and design, check out the Timepaper and the Technical paper.

To demonstrate the power of the Timechain in a multi-chain ecosystem, we are today excited to announce two applications that run on top of the Timechain: the Timegraph and Analog Watch. As a developer, you can leverage the Timegraph and the Analog Watch to deploy and query on-chain data from a broad spectrum of supported chains.

These applications eliminate the need for building complex Web3 data infrastructure tooling to query on-chain data by allowing you to easily deploy and query data — through Timegraph artifacts, such as collections and views — via an intuitive and unified GraphQL endpoint.

Visit https://docs.analog.one/documentation/ to learn more about the Timegraph and Analog Watch.

Visit the following links to start building on the Timegraph protocol:

To progress toward an interoperable Web3 future, it is essential to enhance the capabilities of the Timechain and Timegraph by incorporating the ability to execute smart contracts across multiple chains. Soon, Analog intends to extend the Timechain and Timegraph capabilities to include cross-chain smart contract execution calls. This will provide developers with a simple framework for building cross-chain applications.

Cross-chain smart contract execution calls will transcend the idea of merely wrapping tokens and bridging them between different blockchains. It will enable you to span DApp logic across multiple blockchains seamlessly, scalably, and securely.

Anatomy of Analog’s cross-chain smart contract execution calls

The ability to validate and pass messages from one chain to another is essential to enabling cross-chain smart contract calls. The General Message Passing (GMP) protocol, built on top of the Timechain, is a core feature of Analog’s cross-chain smart contract execution calls.

To get a sense of how Analog’s GMP protocol facilitates cross-chain smart contract calls, let us first take a look at the GMP architecture.

Analog's Public Testnet

Be among the first to experience Analog’s Timechain and the tools that power up the next generation of omnichain DApps.

High-level architecture of the GMP protocol

GMP provides a chain-agnostic standard that any developer can leverage to build secure cross-chain applications; applications that can send messages, transfer assets, and initiate smart contract calls across supported blockchains. At the core of the GMP protocol lies a number of components deployed in both on-chain and off-chain environments, as illustrated here:

  • Gateway smart contracts (GSCs). These are the contracts that Analog Network validators (chronicle workers) leverage on supported chains to:

    • Observe events/states/transactions at specified addresses on the source chain and report them to the Timechain for further validation through MPC processes.

    • Sign and execute cross-chain requests on target /destination blockchains.

  • Gas Receiver Services smart contract (GRS SC). This is a contract that gets deployed on the source chain to manage the payment of transaction fees. It enables the user/application to pay transactions as a single bundle in the source chain’s denominated native token.

  • Security smart contracts (SSCs). These are smart contracts that provide customizable security features. DApp developers can leverage SSCs to determine the shard number (i.e., the minimum number of validators) that should sign off on the cross-chain requests on both the source and destination chains.

  • Time nodes. These are on-chain nodes that leverage the NPoS consensus algorithm to attest to the validity of the proposed blocks on the Timechain.

  • Chronicle workers. These are specialized, off-chain routines implemented within each time node that participates in MPC processes to reach a consensus on the state changes occurring in external chains.

  • Connectors. These are specialized routines implemented in each time node that allow the time node to interact with external blockchains. The chronicle workers fetch the validated transactions/data from the connectors and generate a signed payload that gets transmitted to the time node for further processing and validation via an NPoS protocol.

One primary benefit that the GMP architecture presented above provides in a multi-chain ecosystem is enhancing UX. As it currently stands, interacting with a DApp hosted on different chains is challenging and time-consuming, even for seasoned crypto users. For example, performing a relatively simple operation like a cross-chain swap involves several steps across multiple applications and networks.

You must bridge your assets, perform swaps, and even acquire new tokens to cover the transaction fees. This UX is not good for the Web3 space as it stifles mass adoption while also being prone to security risks.

The GMP protocol improves the overall DApp UX by eliminating the need for users to care about the chain their applications are hosted on. For example, with GMP, a DApp can execute logic on any blockchain network via a single UI. This eliminates the need for them to switch between different applications and chains.

Now that we have explored the GMP architecture, let us examine how Analog intends to roll out its cross-chain smart contract execution feature.

A deep dive into the cross-chain contract execution calls

In this section, we will illustrate how the GMP protocol would enable a simple contract on chain X can initiate a call on chain Y. Using the GMP protocol, a user on chain X can send an arbitrary message from chain X to chain Y and receive an acknowledgment that chain Y has processed the request.

Suppose we have two contracts structured as follows:

contract ContractX❴
...
function functionX(data_type args1, data_type args2) external payable
❴ if (!_isValidChainId(dstChainId)) revert InvalidDstChainId();

contract ContractY ❴
...
function functionY(data_type args1, uint args2) public returns (uint) ❴
...

In this example, we have two contracts: contract X, which is deployed on chain X, and contract Y, a remote contract that we wish to call on chain Y. You can use functionX() to send any arbitrary message from contract X to any chain. In this case, functionX() first checks the validity of the transaction before approving the cross-chain call.

To approve the call, the contract would need to check that you have deposited sufficient fees (in chain X’s native token) in the GRS SC.

Here is how Analog’s GMP protocol would enable you to undertake such a cross-chain contract call:

Cross-chain preparation:

  • First, you will need to install our GMP SDK. Installing this SDK allows you to leverage Analog Network infrastructure and abstract many cross-chain communication details that would have otherwise been difficult to implement on your own. For example, you do not need to install your own GSCs or pay transaction fees in multiple tokens.

  • Import the relevant smart contract (i.e., gateway, security, and gas receiver) from the GMP SDK into your application (contract X).

  • Instantiate the deployed contracts, including GSC, SSC, and GRS SC. These will be the contracts that route the call from chain X to chain Y.

Cross-chain call request (Chain X):

  • Call the send_message () function on the GSC deployed on chain X with the necessary arguments.

  • Prepay the relayer gas fee on chain X via the GSC SC.

  • Once initiated, the call enters the Analog Network Gateway. At the Gateway, the GSC validates the message signature and emits an event with message data if the cross-chain request is valid as follows:

    Contract GSC❴

    send_message (…)❴

    if (messageType == CROSS-CHAIN_REQUEST)
    emit event;
    else
    revert InvalidMessageType();

    • The GSC checks whether the paid gas fees from chain X’s native tokens is enough to cover for the Timechain and chain Y’s transaction fees.

    • Upon successfully validating the cross-chain request, the GSC propagates the transaction to the Timechain, validating it and adding it to the ledger.

    • The Timechain designates one of the validators (chronicle worker) to broadcast the validated and signed transaction to chain Y.

Cross-chain call execution (chain Y):

  • The GSC on chain Y validates the message signature.

  • Upon successfully validating the message signature, the GSC calls functionY( ), which gets executed. After the execution, the response is sent back to the GSC on chain Y, which forwards the acknowledgment to the calling contract (contract X).

Conclusion

We have designed the GMP protocol currently being developed as a native chain agnostic system that will integrate a wide range of blockchain ecosystems. This means the GMP protocol is better positioned to support the multi-chain ecosystem’s shift to cross-chain smart contract execution calls. Compared to traditional cross-chain bridges, the GMP protocol will allow users to securely send arbitrary messages across any supported chain and not merely tokens.

Embark on the cross-chain journey with Analog

Learn how to deploy and query data from the supported chain with our Docs.

Experiment with Analog Watch to quickly deploy and explore blockchain data from listed smart contracts.

Experiment with the Timegraph SDK in less than 10 minutes with our Quickstart guides.

Learn more about Analog Network and its architectural components here.

Join our tech community on Discord to ask any question(s).

Find us on Twitter and Telegram.

Apply to join our Launch Partners Program here.

Apply to join the Developers’ Grant Program here.

Subscribe to our blog

You Might Also Enjoy

Decoding Interoperability Solutions

We have witnessed many blockchain networks emerging over the past couple of years, each with its own strengths and weaknesses. Some of these blockchains have different degrees of decentralization, security, throughput, or transaction fees.

Read more rightArrow

Web2 To Web3: Bridging The Gap From The Developers’ Perspective

The true essence of the web is the democratization of communication and knowledge. From its initial roots as Advanced Research Projects Agency Network (ARPANET), the web has been leveraged to close…

Read more rightArrow

Exploring Cross-Chain Decentralized Exchanges: A Comprehensive Overview

Decentralized Exchanges — or more simply DEXs — are peer-to-peer (P2P) marketplaces that allow crypto traders to trade their tokens directly without handing over the management of their assets to an intermediary.

Read more rightArrow

Decoding Interoperability Solutions

We have witnessed many blockchain networks emerging over the past couple of years, each with its own strengths and weaknesses. Some of these blockchains have different degrees of decentralization, security, throughput, or transaction fees.

Read more rightArrow

Web2 To Web3: Bridging The Gap From The Developers’ Perspective

The true essence of the web is the democratization of communication and knowledge. From its initial roots as Advanced Research Projects Agency Network (ARPANET), the web has been leveraged to close…

Read more rightArrow

Exploring Cross-Chain Decentralized Exchanges: A Comprehensive Overview

Decentralized Exchanges — or more simply DEXs — are peer-to-peer (P2P) marketplaces that allow crypto traders to trade their tokens directly without handing over the management of their assets to an intermediary.

Read more rightArrow
Contact Us
Go to Top