Published in


「Build on Darwinia 2–5」Understanding Crab Chain and Crab Smart Chain


There are two chains in the Darwinia Crab network, Crab Chain(CC) and Crab Smart Chain(CSC). They provide two sets of interfaces and chain structures but share the same nodes network, state storage, and native token(CRAB). Crab is Darwinia’s canary network.

Crab Chain

CC is the native standalone chain of Darwinia Crab based on Substrate with a set of dispatch calls defined by its runtime, so its chain type is Substrate. The address is of Substrate SS58 format with prefix 42, and the decimal is 9. The node of CC provides substrate RPC endpoint for reading chain states and sending extrinsics which can be included in Substrate blocks, and these blocks are chained together as a Substrate blockchain in the network. The CC data is available at Subscan.

Crab Smart Chain

CSC is for EVM compatibility, and provides users with the ability to create and interact with smart contracts. In the dispatch calls of CC, there is a special one called Ethereum.transact which is used for Ethereum transaction.

/// Transact an Ethereum transaction.
#[pallet::weight(<T as darwinia_evm::Config>::GasWeightMapping::gas_to_weight(transaction.gas_limit.unique_saturated_into()))]
pub fn transact(
origin: OriginFor<T>,
transaction: TransactionV0,
) -> DispatchResultWithPostInfo

To be compatible with the EVM chains and infrastructures such as MetaMask and The Graph, Darwinia Crab node provides Ethereum-compatible JSON-RPC endpoint for reading and sending Ethereum transactions. For each substrate block, CSC builds an Ethereum block that has all Ethereum transactions from it. The Ethereum blocks make up a new chain, which we call CSC. And as a result, CSC meet the requirements of Ethereum interfaces, therefore we can think of it as a different chain which we call Crab Smart Chain(CSC).

Since CSC is Ethereum-compatible, its address format is of Ethereum and the decimals is 18, which are different from CC. The chain ID of CSC is to be determined since it is not launched yet, while the chain ID of Crab Chain is 44, which can be checked from Chainlist.

The technique behind CSC to provide Ethereum compatibility is called Darwinia Virtual Machine(DVM), an extension of Parity’s Frontier.

Go to CSC explorer for an overview of CSC, or have a look at the CSC blocks at the bottom of CC block on Subscan.

Interoperation between CC and CSC

CC and CSC have different account format. CC uses SS58 address format with 32-byte account ID while CSC uses Ethereum format(H160).

In most cases, CC and CSC interact with different parts of the storage. CSC interacts with storage in the EVM pallet and the account data(nonce, balances, etc.) while CC interacts with storage in other pallets and the account data, and the account data is the shared part. However, because the storage keys of the addresses for these two chains are designed to locate in different key spaces, they will not interfere with each other except when interoperation occurs.

Here is an overview of the key spaces in account data storage for this two kinds of addresses.

Then how to perform interoperation between CC and CSC?

CC and CSC provide several useful approaches for interoperation, just like a bridge between two chains.

For Users

If you want to transfer CRAB token between CC and CSC, you can use smart app developed by Wormhole team. They plan to merge this feature into Wormhole later to serve as an instance of token bridge, which will provide a more user-friendly interface and all the cross-chain transfers can be done in one place.

Other developers can also develop dApps to provide similar services to users. The interfaces and methods are as follows:

  • From CC to CSC

Use the Balance.transfer dispatch call to interoperate and transfer balance to CSC.

pub fn transfer(
origin: OriginFor<T>,
dest: <T::Lookup as StaticLookup>::Source,
#[pallet::compact] value: T::Balance,

The origin is the account sending CRAB in CC, and the dest is the CC’s account derived from the destination Ethereum account. For deriving CC account from Ethereum account, read the references of the “Address key generation in account data storage” (To be renamed from “Darwinia Address Format Overview”), or use our dvmaddress tool.

A quick preview:

  • From CSC to CC

If you want to transfer CRAB from a CSC Ethereum address or smart contract, you can use the “Transfer” Precompile contract. For more details, go to the precompile contract document [1] [2].

Note: The CC and CSC use different address formats and decimals for CRAB token. On CSC, the native token decimals is 18, while the decimals on CC is 9. So if you transfer 1e9:CRAB to CSC, the recipient account will receive 1e18 in its balance.

For Developers

If you are developer, you can do more interoperation between CC and CSC besides balance transfer through a dispatch call, Ethereum.root_transact, and a Precompile, Dispatch.

For example, if you want to call some contract from a CC account by sending an extrinsic, you can use the Ethereum.root_transact dispatch call. Since it is still experimental, it can only be called from CC’s Root origin for now, but there could be other specific dispatch calls for other CC’s origin later. If you are a runtime developer of Darwinia Crab, you can also interact with CSC using the internal call Ethereum.internal_transact, which is a part of the runtime and protocol and can only be modified through CC’s governance mechanism.

Conversely, if you want to call some dispatch calls in CC’s runtime through an Ethereum transaction or from an EVM smart contract, you can use the Dispatch precompile contract. This precompile contract will help the msg.sender Ethereum address use its CC’s address as the call origin, and make a pallet level dispatch call via a special Ethereum transaction which input field is the encoded dispatch call data. Fore more details, go to the precompile contract document [3].

Note: The CC and CSC use different address formats and decimals for CRAB token, on CSC, the native token decimals is 18, while the decimals on CC is 9.


In this article, we introduced the concepts of Crab Chain(CC) and Crab Smart Chain(CSC) and explained the architecture and design goals of the two chains. Then we described more differences between them, including chain type, chain ID, address format, decimals, and account data storage key allocation, which can give reader a better understanding of CC and CSC. In addition, we introduced the interoperation methods between CC and CSC, for users and developers.


  1. Transfer precompile implementation v2.8.1:


2. DVM system contract document:


3. Dispatch precompile implementation v2.8.1:



Developer Documentation: https://docs.crab.network/builders/get-started/darwinia-dev

Developer Telegraph Group: https://t.me/DarwiniaDev

Darwinia DApps Builders: https://t.me/+fJiD_IwvwjhjYmQ9

Discuss: https://github.com/darwinia-network/darwinia/discussions

About Crab Network

Follow Us: [Github] [Website] [Medium] [Telegram] [Twitter]

🔥🔥🔥 Crab Network is holding an online hackathon on the DoraHacks platform to fund the development of projects and applications that contribute to the Crab ecosystem and promote overall network growth. The USD 107,000 in the prize pool, will be allocated based on the votes of the judging panel.

Crab is a canary network with real economic value for Darwinia, and its positioning is similar to Polkadot’s Kusama Network. Crab Network has won the 22nd Kusama parachain slot! You can check Crab status through Polkadot{.js} , Subscan or Subview.

Crab provides smart contract solutions based on DVM (Darwinia Virtual Machine), which is compatible with the EVM (Ethereum Virtual Machine) paradigm. Therefore, it is easy for projects in the Ethereum ecosystem to migrate to the Crab Smart Chain. (Tips: DVM is built on Frontier with a fully EVM-compatible instruction set and an Ethereum RPC-like external interface.)



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store