
SubBridge pallet
- The destination is already supported by a certain bridge, that is, the SubBridge will traverse the list of bridges to check whether the bridge supports transfers to the destination address, and if so, use this bridge for forwarding.
- Make sure that the format of the path conforms to our specification [see next section] and still has enough assets as a fee to pay the cross-chain fee to the other chain.

SubBridge Topology
MultiAsset and MultiLocation
The purpose of SubBridge is to connect assets in multiple chains. Therefore, how to unify the definitions of assets and locations in multiple chains is the first problem we need to solve. After research, we thought of MultiAsset and MultiLocation in the Polkadot XCM protocol. MultiAsset is used to represent a certain asset on a certain chain. For example, the asset of PHA can be expressed as:Whereamount
is a certain amount of asset,pha_location
is the path of PHA under the XCM protocol standard, which is defined by SubBridge and represented by MultiLocation, usually represented as:
Among them, 2035
is the parachain ID of the Phala network. So how do we use the XCM protocol to represent any non-parachainâs account address? It determines how SubBridge will recognize and forward cross-chain transactions.
What we do in practice is that we incorporate other non-parachains into sub-addresses of the Phala network, similar to the local area network specified by TCP/IP. In this way, the account address of an EVM chain can be represented as:
Among them,Similarly, the assets of any chain also need to be unified. The assets on the parachain are defined by the team of the parachain to define their corresponding MultiAsset; the EVM chain assets based on SubBridge are also defined as the sub-asset of the Phala network like the account address. That is, the usual asset location would be represented as:bridge
represents a specific bridge, for example, SygmaBridge uses sygma to represent; ChainBridge usescb
to represent;chain
represents the ID of the EVM chain under the EVM Bridge system. Currently, Ethereum is 0 under both SygmaBridge and ChainBridge protocol;account
represents the ID on the EVM chain. An account, usually a 20-byte hexadecimal string.
Among them, token
represents the contract address of a certain ERC20 or ERC721 of EVM.
Asset Registration
The registration of SubBridge assets is mainly divided into two parts: The first part is to register assets into the pallet-assets module. SubBridge uses the pallet-assets module provided by Substrate to manage the registered assets. The registered assets will be assigned an asset id. Each asset has an extra registry info which contains information of location, enabled bridges and properties. Unregistered assets will fail regardless of whether they are transferred via the EVM bridge or the XCM bridge. The second part is to enable the corresponding EVM bridge. This part is only for the asset settings that want to carry out the cross-chain requirement from Phala to the EVM chain. In SubBridge, the same asset can enable both SygmaBridge-based bridges and ChainBridge-based bridges. In practice, users are always willing to choose solutions with lower fees. The steps to do the registration stuff are as follow:-
Step1, we schedule a call of
pallet-registry::forceRegisterAsset
with given registration informations. When the council enacted the call, an asset instance will be created bypallet-assets
, and some extra registration information will be saved inpallet-registry
. There are several things we need to pay attention to. The first one is that each asset has a bunch of metadata defined inpallet-assets
, likename
,symbol
, etc. We have provided an extrinsic calledforceSetMetadata
inpallet-registry
which can be used to update the metadata of an asset. Another one is that each asset has some privileged accounts used to manage the asset, likeIssuer
,Admin
, etc. Different account has different permission. Inasset-registry
, we set all the privileged accounts of each asset to an account derived byPalletId(b"phala/ar")
. This means no external account has permission to do things beyond authority. All registered assets can be found at here. The asset registration informations are stored on-chain, head to polkadot.js.app and choose RPCassetsRegistryâregistryInfoByIds
to see details. Here is a screenshot of KSM registration information:Registration infomartion of KSM
Note: For assets on Phala, also can be found on Assets
tab in polkadot.js app
-
Step2[optional], after the asset was registered, by default all assets will enable XCM crosschain transfer. If the asset is going to enable SygmaBridge or ChainBridge, another call named
assetRegistry::forceEnabledSygmaBridge
orassetRegistry::forceEnabledChainbridge
should be enacted by the council. This will enable the crosschain transfer to a specific EVM chain. AndassetRegistry::forceDisableSygmaBridge
orassetRegistry::forceDisableChainBridge
is used to disable it. When SygmaBridge or ChainBridge was enabled for the asset, you will see we have new data being added to the returned registration information. For example, the enabled-bridges information of ZLK is shown below:Looking at the ChainBridge filed, thechainId
is 2 means it has enabled crosschain transfer between the Phala network and Moonriver EVM.ResourceId
is used to bind ZLK on the Phala network and ERC20-ZLK on Moonriver EVM.reserveAccount
is used to save ZLK temporarily when transferring ZLK from the Phala network to Moonriver EVM, and will transfer back to the recipient account when someone transfer ZLK from Moonriver EVM back to Phala network.isMintable
isfalse
tells the client that should aware of the ZLK balance of reserve account. -
Step3[If Step2 has been done], we also need to config your asset in our ChainBridge Bridge contract before finally launching the crosschain transfer through ChainBridge. It including:
- Binding resource id generated during registration with its ERC20 contract address. This essentially is done by executing method adminSetResource of Bridge contract.
- Set decimals of the asset by executing method adminSetDecimals. SubBridge is compatible with the scenario that asset has different decimals between substrate side and EVM side.
- If your asset is burnable and would like to give the mint/burn permission to our contract, we need to tell the contract to mark your asset as burnable by executing method adminSetBurnable. With burnable set, when the user transfers asset from EVM chains, the asset would be burned directly from their account, and mint to the recipient account when someone transfers back to EVM chains.
Note: For SygmaBridge, asset config need to be done by Sygma team.
The Lifecycle of Cross-chain Transaction

Lifecycle of SubBridge Cross-chain Transaction
Other
SubBridgeâs SygmaBridge in mantained by Phala team and Sygma team together. The substrate side is exist on Phala network, the smart contract on EVM side is deployed by Sygma team and the liquidity is maintained by both Phala team and Sygma team through multi-sig account. SubBridgeâs ChainBridge cross-chain bridge module is maintained and developed by the Phala team and is responsible for running three Relayers. The Relayer of the ChainBridge cross-chain bridge constructs the captured origin chain cross-chain transaction into a proposal, and then the three relayers vote on the Proposal. After the vote is passed, the proposal will be executed and the assets will be deposited in the user address. About ChainBridge, you can refer to their website. For the Phala Ethereum ChainBridge contract, please refer to the source code on github.Code Auditing
The bridges currently integrated by SubBridge include 3 implementations, XCM, SygmaBridge, and ChainBridge. XCM is a cross-chain message protocol implemented by Parity Tech in the two networks of Polkadot and Kusama. Its code has been audited by a third-party audit firm hired by Parity. The audit report on XCM V2 (the current version of XCM used by SubBridge) can be found here As for SygmaBridge, both the solidity smart contract and substrate pallet are get audited, the audit report can be found here Earlier 2022, we deployed ChainBridgeâs Solidity contract on Ethereum. The contract info can be found here. Recently we migrated the old contract to the new deploy one0x8F92e7353b180937895E0C5937d616E8ea1A2Bb9
. Up to now, the contract has been running safely for nearly a year, and the contract has also been audited by Certik, a third-party auditor hired by Phala. The detailed audit report can be found here
Reference
- XCM format: https://github.com/paritytech/xcm-format
- MultiAsset definition: https://github.com/paritytech/polkadot/blob/master/xcm/src/v1/multiasset.rs
- MultiLocation definition: https://github.com/paritytech/polkadot/blob/master/xcm/src/v1/multilocation.rs
- Phala ChainBridge Solidity contract: https://github.com/Phala-Network/chainbridge-solidity/tree/phala-bridge
- Pallet-assets implementation: https://github.com/paritytech/substrate/tree/master/frame/assets
- Introduction to ChainBridge: https://chainbridge.chainsafe.io/
- Introduction to CelerBridge: https://cbridge-docs.celer.network/