Bring the Program to the Asset

Cross-chain function calls on Axelar allow applications to interoperate without moving assets.

NEWS
TECHNOLOGY
December 16, 2022
Sergey Gorbunov
December 16, 2022

Table of Contents

Back to blog

In traditional distributed systems, it’s common to think about tradeoffs between data and program locality and where compute should happen [in cloud vs. on edge servers, vs. on local devices, etc]. To efficiently compute a program P on some data D, both P and D need to reside in the same environment. [Basically, they need to be on the same computer.]

Traditional distributed systems offer choices: either program P or data D can be moved together into the optimal environment for the task at hand. To date, blockchain infrastructure has not provided those choices when operating cross-chain. That is changing: decentralized application [dApp] developers now have the ability to move the program to the asset, composing cross-chain function calls using General Message Passing.

Example: traditional computing

To better understand the tradeoffs involved between data and program locality, let’s briefly look at an example from traditional computing: If you store a database of patient records in AWS, and want to compute a program P on it, should you do it in AWS or on your local computer?

If P is a machine-learning algorithm that must be executed on the entire set of records, then it’s easier to “send” P to AWS, and compute everything there, and then return the result to your local computer. On the other hand, if you want to run a program that creates a PDF report of a single user’s record, then you can download it to your local computer, and run the program locally to produce the PDF. The right choice highly depends on the size of the data, runtime of P and download speed, among other factors.

Current state in blockchain infrastructure

To date, most blockchains have supported simplistic modes of bridging assets across chains. Users have wrapped assets such as ETH from Ethereum to wETH on Avalanche, and then used them in smart contracts, such as automated market makers [AMMs]. With General Message Passing, we can go way beyond this. Instead of moving assets, we can use cross-chain function calls bring instructions to where the assets are, execute them, and synchronize the state cross-chain.

Example: cross-chain NFTs

Let’s see a single example demonstrating the power of this. Suppose you own an NFT Llama on Solana and want to take a loan against it in USDC in USDLoaner on Ethereum. One way of doing this is to “bridge” your Llama from Solana to Ethereum. The bridge should lock the Llama on Solana and copy its metadata on Ethereum. Then you can take a loan against it in Loaner.

Alternatively, you can lock the Llama on Solana and execute a cross-chain function call to USDLoaner on Ethereum stating that the Llama is locked and specifying the key to which the loan should be issued on Ethereum. USDLoaner would subsequently authorize the request and issue the ETH to the user’s wallet. If you want another user to receive USDC on Avalanche in exchange for your NFT, you can also encode that in the message, and have a contract on Ethereum that would send the USDC to Avalanche to the user’s address.

Advantages of cross-chain function calls

What are the advantages of cross-chain function calls versus bridging assets?

Efficiency: Depending on the size of the metadata behind the NFT, one cross-chain message may be much smaller than the other. Moving NFT metadata is likely to be a larger message than a cross-chain function call indicating that the NFT llama is locked and specifying the key to which the loan must be issued.

Cost: Smaller messages result in cheaper gas costs for the users.

Minimizing fragmentation: If an NFT collection remains on a single chain, it’s easy to trace its provenance and state. On the other hand, NFTs that are bridged across multiple chains would need to be traced and audited using tools that can work cross-chain.

Simple user experiences: Instead of bridging the asset and executing separate transactions to take a loan on the destination chain, the user can fold their entire “intent” in a single transaction on the source chain. One transaction, one fee, one front-end to interact with.

Conclusion

As you can see, cross-chain General Message Passing opens new coding possibilities. The difference is comparable to what you can do on Bitcoin vs. what you can do on Ethereum. On the Bitcoin network, you can mainly send BTC from one user to another [with very limited scripting support]. On Ethereum, you deploy code in a Turing-complete programming environment and perform arbitrary computation over the assets.

General Message Passing takes that concept of Turing completeness and extends it to the cross-chain decentralized web. Developers in this permissionless universe can use cross-chain function calls to compose any function and any asset, on any chain, depending on the optimal choices for their use case and their users.

We’re just getting started defining the future of cross-chain interactions between chains and it’s exciting to see what’s ahead.

Interested in building? Join our Discord, read our example docs, and check out the developer grant program.

Start building with Axelar: