January 12, 2023

Zeta Chain

ZetaChain's Omnichain Toolkit

ZetaChain offers a complete toolkit for developers to build omnichain applications using omnichain smart contracts and/or cross-chain messaging. Here is an overview of these two features and their use cases. For a deeper dive into the different use cases, check out Smart Contracts vs. Messaging.

Omnichain Smart Contracts

Omnichain Smart Contracts are contracts deployed on ZetaChain that can use and orchestrate assets on connected chains, as well as on ZetaChain. With Omnichain Smart Contracts, you are able to have a single place of logic that can maintain the state of assets and data across all connected chains.

Omnichain Smart Contracts are ideal for more complex applications where state management between different chains is core to the application. Some use case examples include:

  • Complex trading or DeFi applications that involve liquidity on multiple chains.
  • Adding smart contract layer to non-smart-contract chains like Bitcoin and Dogecoin, or incorporating these chains/assets with other pieces of the DeFi ecosystem natively.
  • Multichain smart-contract wallet applications like portfolio management across all chains.
  • Leveraging existing implementations of protocols like Aave, Uniswap, Curve, etc. for omnichain. Since zEVM is EVM-compatible, one can build on top of these implementations (just as they would on Ethereum) to adapt them for omnichain interoperability.

Cross-Chain Messaging

Cross-chain messaging lets you send messages from any connected chain to any connected chain, including ZetaChain. Cross-chain messaging makes the most sense for applications that generally need minimal logic or state to maintain across all chains, and where data that needs only to be passed between different chains one way.

A good example of this is an application that needs only to call a contract or send value to an address on a different chain. After the message is received and processed on the destination, the application ideally doesn’t have to broadcast anything back to synchronize state for anything, and the sender doesn’t care about the results.

Cross-chain messaging works to build a variety of applications and primitives such as:

  • Omnichain NFTs that can be sent between different chains, and that don’t need to know about the state of the collection on other chains
  • “Simple” swap or bridge apps that use liquidity pools on existing chains
  • Proving ownership of NFTs or simple action-calls to a different chain

Omnichain Smart Contracts vs. Messaging

As you start in developing your idea, you might wonder: how should I build my dApp? Here are some considerations to help inform decisions about your application architecture:

Deciding on an architecture

The older solution—message passing—uses ZetaChain only as a relay to forward messages to another blockchain; e.g. Ethereum → BSC. A dApp would deploy at least one contract on each connected chain. The states & logic of the dApp is scattered across all of these contracts on these chains which are connected by asynchronous messages. This makes sense for certain applications that only need unidirectional and asynchronous logic/effects and that don’t need or benefit from a unified state.

The novel architecture using Omnichain Smart Contracts and ZRC-20 tokens has a very different topology: only one contract on zEVM is needed for a dApp; no dApp contracts are needed on foreign chains. The zEVM manages foreign coins via the ZRC-20 contracts.

dApps can leverage either one of these solutions based on the following considerations:

dApp complexity

More complicated dApps may prefer Omnichain Smart Contracts because the logic & state is more centralized, whereas with messaging, you must broadcast messages and state sync across many contracts on different chains, which can lead to substantially more attack surface and more gas fees (each message requires additional gas to be paid, and the number of messages you must send to maintain a full state sync scales).

Building on top of existing EVM contracts

Common applications like Uniswap V2/V3, Curve, Aave, Compound, and so on that have been audited and battle-tested on Ethereum can easily be deployed and built on top of in ZetaChain. One can extend these applications by adding in compatibility with ZRC-20, but those changes are minimal and the majority of logic may remain the same, and users may interact with these applications in single-step transactions just as they would on Ethereum. On the other hand, with messaging, in many situations (especially those that are more complex), a developer must “recreate the wheel” — recreating the logic in a completely different, asynchronous messaging and state-sync system; messaging cannot leverage existing applications in the same way.

Support of less-smart-contract chains

ZRC-20 can easily support Bitcoin/Algorand/Cardano/XRP which do not have capability or efficiency to support general purpose smart contracts for applications like swapping, lending, etc. Messaging cannot work for these chains, because messaging requires smart contracts on any connected chain.

Foreign gas cost

ZRC-20 may cost significantly less gas than message passing in many use cases because its interactions with foreign chains are confined to fungible coins (standard value transfer of ETH/BNB/MATIC costs 21k gas, moving ERC20 tokens costs around 60k gas; no logic/state on foreign chains means much less gas). Message passing inherently requires processing message data on the source/destination chains which adds additional gas costs for things such as validation, verification, parsing, and so on.

Unifying liquidity

With omnichain smart contracts, you can pair and trade native asset liquidity directly against each other. This minimizes steps to trade native assets (a single step), and neither involves a bridge or wrapping step nor sending complex messages. For example, you could trade Ethereum ETH directly for Polygon USDC through a unified pool in a single transaction. With messages, you can leverage existing liquidity like Uniswap pools on existing chains, and trade via burning/minting ZETA through ZetaChain. This approach may be more complex (more transactions involved, more gas), but doesn’t rely on liquidity within ZetaChain’s ecosystem. While omnichain smart contracts and messaging both provide approaches to unified liquidity, it's up to the developer to choose based on his system requirements.

Exception handling

With ZRC-20/zEVM, exception/revert handling is much simpler, as foreign interaction is confined to either a standard ERC-20/contract interaction (success) or no contract interaction (failure) immediately as the transaction is processed. In comparison, although messaging supports reverts, a dApp (and user) must blindly wait for and handle errors in an asynchronous/event-driven way.

At a high level, fees are bundled for users of ZetaChain dApps, whether they use cross-chain messaging and/or smart contracts. These fees are distributed to parties providing value to the network in the form of creating transactions, securing the network, or other direct protocol contributions.

Both CCTXs and Smart Contracts have a base fee which is burned (see fee distribution below), and a variable fee. For CCTXs, this is a variable fee proportional to data (kb) sent, while smart contracts have a fee market like EIP 1559. Eventually, CCTXs will transition into a fee market similar to a tip/priority fee structure.

Base Fee

ZetaChain includes a base flat fee of (example) 0.01 ZETA for any transactions, cross-chain messaging transactions or smart contracts. This base fee is adjustable by the network as needed to deal with network traffic and congestion, and is burned.

More details and breakdowns on gas fees involved with Cross-Chain Messaging and Omnichain Smart Contracts will be written.

ZetaChain enables you to write smart contracts that execute actions and orchestrate assets on multiple connected chains, including on ZetaChain directly. For example, a single transaction may transfer an ERC-20 on Ethereum and then move some Bitcoin from one address to another. Leveraging this, developers can build applications with a seamless UX, that span across all chains, and that unlock new opportunities for users in verticals such as DeFi, NFTs, Gaming, DAOs/Governance, Identity, and more.

Twitter - https://twitter.com/zetablockchain

Discord - https://discord.com/invite/kjQBqcZtnh

Telegram - https://t.me/zetachainofficial

Reddit - https://www.reddit.com/r/zetablockchain/

Mission Bring ZETA Home Testnet Campaign

Galxe - https://galxe.com/ZetaChain/campaign/GCatUUwYSY

Crew3 - https://zetachain.crew3.xyz/questboard

Quest3 - https://app.quest3.xyz/quest

Port3 - https://soquest.xyz/space/ZetaChain