Why Integrating SubBridge
A TL;DR answer is that: SubBridge greatly reduces the efforts to transfer your assets to/from multiple blockchains. Generally speaking, it takes two steps to bridge your asset to another chain:- To find an asset route to your target chain so you can transfer your token there, which may be consisted of one bridge or multiple bridges;
- To ensure that your token can be recognized and handled in the target chain, this usually involves ad-hoc negotiation and program development;
- Instead of connecting your chain to others one-by-one, by integrating SubBridge you will be able to get the routes to any other chains that have already supported SubBridge (for now, this includes Polkadot parachains, Ethereum and Moonriver EVM);
- SubBridge provides a unified interface (based on Polkadot XCM protocol) to abstract your asset and the corresponding asset-handling example, also our technical team is glad to provide support during your integration.
Overview
SubBridge supports both parachain assets and EVM assets, making it possible to transfer them between parachains and EVM chains. All supported assets are whitelisted, which means it would be failed if you transfer assets through SubBridge without registration. Refer to Supported Assets to check the asset list we have integrated.- A parachain asset means the asset is reserved on a parachain. For example, GLMR is reserved on Moonbeam.
- An EVM asset means the asset is reserved on an EVM chain, in general, it’s an ERC-20 smart contract deployed on EVM. Note we currently only support assets deployed on Ethereum and Moonriver EVM.
- Open an issue on subbridge-integration repo to provide asset registry information;
- Test registration locally or on Rococo;
- Register assets on Khala Network;
- [Optional] Integrate SubBridge into your app;
Provide Asset Registry Information
If you are interested in integrating your asset into SubBridge, please go to integration repo to open an issue with the template below:location
must be a MultiLocation. For example, the location ofKAR
isMultiLocation::new(1, X2(Parachain(2000), General(0x0080)))
. If your asset is an EVM asset, thelocation
should beMultiLocation::new(1, X3(Parachain(2004), GeneralIndex(chain_id), GeneralKey(erc20_address)))
.chain_id
should match the chain your asset deployed on. So far chain id of Ethereum is0
, and chain id of Moonriver EVM is2
.is mintable
represents whether your ERC20 smart contract supportmint
andburn
, if set as true, your users will need to give the mint authority to our contract when the first time they use SubBridge. Check Assets Registration find more details about what we have done on registration.
Test Registration
Before onboarding your asset to the Khala network, we must make sure everything works properly on the Rhala network, which is our test parachain on Rococo. For parachain assets, you can choose to test the registration locally before running a test with the Phala team on Rococo. We have provided a config file which contains the information on how to run our test runtimeThala
with polkadot-launch
. Check here to find more about polkadot-launch
.
For both parachain assets and EVM assets, the necessary step is to test the whole integration stuff on Rococo with the Phala team. The parachain registration on Rococo is maintained by Parity, if you are a parachain asset and you haven’t been a Rococo parachain, please notice the Parity team to onboard your chain on Rococo, also don’t forget to let them open HRMP channels between your parachain and Rhala network. If you are an EVM asset, please deploy an ERC20 asset on Kovan in advance, which will be used to config the EVM bridge. The architecture of the test net is as follow:

Rhala Testnet Architecture
Contract | Address |
---|---|
bridge | 0x0316Ea56000BCdB7D7EAED54fd70898a1fF90C09 |
erc20Handler | 0x7b11b07318E2E01b28A75da99F7EB8d635A6d46b |
- For parachain asset, please transfer 10000 of your asset to account
0x7804e66ec9eea3d8daf6273ffbe0a8af25a8879cf43f14d0ebbb30941f578242
on your parachain - For EVM asset, please transfer 10000 of your asset(ERC20) to account
0xA29D4E0F035cb50C0d78c8CeBb56Ca292616Ab20
on Kovan
Register assets on the Khala network
After we have confirmed all functions are working properly on Rococo, we will start integrating your asset on the Khala network. If your asset is a parachian asset, please refer to Parachain assets integration guide and if your assets is an EVM asset, please refer to EVM assets integration guide.Parachain Assets Integration Guide
SubBridge contains an XCM-based bridge that can let assets transferred between parachains. If the parachian your asset reserved hasn’t opened HRMP channel with Khala network, the first thing we should do is follow these steps to open bi-direction HRMP channels:💡 Steps 1 - 3 are the stuff to open HRMP channels between our two parachains. You can directly jump to Step 4 if it has been done. Information of PHA are as follows:
Type | Value |
---|---|
Name | PHA |
Symbol | PHA |
Decimals | 12 |
ED | 0.01 PHA |
Location | MultiLocation::new(1, X1(Parachain(2004)) |
- Head to: https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fkusama.api.onfinality.io%2Fpublic-ws#/extrinsics
- Choose extrinsic with parameters: hrmp -> hrmpInitOpenChannel
{ recipient: 2004 , proposedMaxCapacity: 1000, proposedMaxMessageSize: 102400}
- Copy the encoded call data, it should be
0x3c00d4070000e803000000900100

Send HRMP Open Request
- WithdrawAsset
- BuyExecution
- Transact
- RefundSurplus
- DepositAsset
0x03000821040101009d1f02000000210001010002140004000000000700e876481713000000000700e876481700060002286bee383c00e7070000e803000000900100140d0100040001010070617261d4070000000000000000000000000000000000000000000000000000
, you can decode the call at page https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fkhala.api.onfinality.io%2Fpublic-ws#/extrinsics/decode
Tips:
- Make sure the XCM message is sent from the root account (either SUDO or via governance)
- Make sure your parachian sovereign account has enough KSM on the Kusama network
- The destination should be (1, Here)
- Asset id(MultiLocation) should be set to (0, Here)
- Recipient of
DepositAsset
should be anAccountId32
and put your parachain sovereign account public key to id field.
💡 Please let us know when the XCM message is executed successfully on Kusama, then we will propose to send an XCM message to receive the request and send open the request to your parachain at the same time.Step 3: Receive HRMP open request from Khala network HRMP channel is a one-way channel, which means you also need to receive our open request on your side or your parachain will not be able to receive messages from our parachain. The steps to receive the request from the Khala network are similar to the open request we did before. When the Khala network successfully sends the open request, you should do as follow:
- Head to https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fkusama.api.onfinality.io%2Fpublic-ws#/extrinsics
- Choose extrinsic with parameters: hrmp -> hrmpAcceptOpenChannel
{ sender: 2004 }
- Copy the encoded call data, it should be 0x3c01d4070000

Accept HRMP Open Request
PHA
is MultiLocation::new(1, X1(Parachain(2004)). You may want to add it to your runtime XCM trader config according to your implementation.
EVM Assets Integration Guide
If the smart contract of your asset is ERC20 compatible, we can easily integrate it into SubBridge. Currently, we have integrated ChainBridge as our EVM bridge. It already deployed on both Ethereum mainnet and Moonriver EVM, here is the deployed ChainBridge contracts information:- SygmaBridge smart contract info
- ChainBridge smart contract info
Contract | Address |
---|---|
bridge | 0x8F92e7353b180937895E0C5937d616E8ea1A2Bb9 |
erc20Handler1 | 0xEEc0fb4913119567cDfC0c5fc2Bf8f9F9B226c2d |
erc20Handler2 | 0xcd38b15a419491c7c1238b0659f65c755792e257 |
Contract | Address |
---|---|
bridge | 0xCe6652551A989C13B41f70cac504341A5F711c8d |
erc20Handler | 0xf88337a0db6e24Dff0fCD7F92ab0655B97A68d38 |
Relayer | Address |
---|---|
relayer1 | 0xA97Dc452Ca3699c4Eb62171FE2f994ff7aE48400 |
relayer2 | 0xdca0f5B3686cc87415100808a2568879fE74E01a |
relayer2 | 0x4EE535bE2ce432151916E36B3c684E1dB8Cbf8c1 |
💡 You should receive the update when we finish the registration.
Integrate SubBridge into Your App
It’s better to integrate SubBridge into your App if you’d like to let your users use it easily. Integrating SubBridge into your app is super easy, the only thing you need to do is follow thedest
specification we defined previously on your client. The difference between doing crosschain transfer on a parachain and an EVM chain is that in the former case you will need to interact with the XCM implementation pallet on that parachain, while in the latter you will need to interact with the smart contract deployed by Phala.
- Issuing crosschain transfer on other parachains or Phala network
- Issuing crosschain transfer on EVM chains with SygmaBridge
Bridge.deposit
which is the interface to issue crosschain transfer we need to call ERC20 approve method to let user approve the specific amount of assets to ERC20Handler
contract of SygmaBridge. This operation will allow ERC20Handler
to spend up to the specific number of assets from the user account. After approval done, we can deposit asset through SygmaBridge contract. Luckily, Sygma has provided SDK to handle all of these stuffs, head to their SDK repo for more details.
We prepared the following 5 examples that almost covered all of the scenarios. If the transaction is issued on parachain, we have provided an encoded call you can decode on https://polkadot.js.app, and if the transaction is issued on EVM chains, we have provided a code snippet.
Example1: transfer an asset from Phala network to other parachain
An example of transferring 100 PHA from the Phala network to Moonbeam, the recipient address is 0xA29D4E0F035cb50C0d78c8CeBb56Ca292616Ab20
:
0xA29D4E0F035cb50C0d78c8CeBb56Ca292616Ab20
. Note small amount of PHA will be deducted as the fee of SygmaBridge:
Alice
. Karura XCM transfer based on the implementation of [xtoken pallet]https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xtokens):
0xA29D4E0F035cb50C0d78c8CeBb56Ca292616Ab20
. Note small amount of PHA will be deducted as the fee of SygmaBridge: