Side Chain -> Main Chain
Quickstart on how to integrate the flow of porting from a side chain back to the main chain of a token.
Port in from Side Chain back to Main Chain
This section describes how to bridge back from a side chain (using the Chainport minted token) to the main chain. Note that, when bridging back to the main chain, the token you redeem on the target chain is the original native token.
Bridging back from side chain to main chain, you must call the burnTokens
function on the ChainPortSideBridge
smart contract:
This function required to add Value to the transaction in order to success. There is a getter for that amount:
Value is required in order to cover the gas cost of minting and receiving the ported tokens on the target chain.
Copy
First make sure to approve spend on the ERC20 token you would like to bridge
Copy
Parameter | Type | Description |
---|---|---|
bridgeToken |
| The address of the token you wish to bridge. This is the address of the Chainport minted token on the side chain. |
amount |
| The amount of tokens you wish to bridge, in wei. |
networkId |
| the destination chain network id. The following endpoint will fetch the list of network ids: |
affiliate |
| Your affiliate address. If you dont have an affiliate address, pass in the zero address. To get an affiliate address and participate in our revenue sharing program please reach out to us on telegram. |
To get the ChainPort minted bridgeToken address for a given native token, use the GET /api/token endpoint.
Calling the burnTokens
transaction on the ChainportSideBridge
smart contract on Polygon Mumbai Testnet, which after 18 block confirmations, results in redeemable funds on Ethereum Goerli Testnet:
PythonCopy
Once the burnTokens
transaction has been mined and the minimum confirmation blocks have passed (check the GET/api/meta
endpoint for the min block confirmations for a given chain), the Chainport bridge will begin to work on transferring your funds to the target network. Usually this process takes up to 5 minutes.
You can check the status of your burnTokens
transaction via the following endpoint:
Check the status of your bridge transaction
GET
https://api.chainport.io/api/port
Returns a port transaction
Query Parameters
Name | Type | Description |
---|---|---|
base_tx_hash* | String | The transaction hash of the |
base_network_id* | String | The source chain Chainport network id. |
200 Port transaction successfully fetchedCopy
Before the bridge transaction reaches the minimum confirmation threshold, this request will return an empty object
Note that a target_tx_status
of 1 indicates the bridge has processed your releaseTokens
transaction on the target network while a target_tx_status
of null indicates that the bridge has not processed your releaseTokens
transaction on the target chain.
Last updated