Main Chain -> Side Chain
Quickstart on how to integrate the flow of porting from the token's original source chain (as originally deployed by the token's creator) to a new ChainPort created token on another chain.
Port out from Main chain to Side chain
This section describes how to bridge a native token from its source chain to a target chain. Note that when bridging from the native tokens source chain to a target chain, the target chain token will be minted by Chainport.
To bridge from a main chain to a side chain, you must call depositTokens
on the ChainportMainBridge
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
Parameters | Type | Description |
---|---|---|
token |
| the address of the token you wish to bridge. |
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. |
Calling depositTokens
on the ChainPortMainBridge
contract on Ethereum Ropsten Testnet, which after 6 block confirmations, triggers a bridge transaction on Polygon Mumbai Testnet:
PythonCopy
Once the depositTokens
transaction has been mined and reaches the minimum block confirmation threshold (check the GET/api/meta
endpoint for the min block confirmations for a given chain), the ChainPort bridge will initiate a mint transaction on the target chain. Usually this process takes up to 5 minutes.
You can keep track of your bridge 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 transaction on the target network. When target_tx_status
is 1 you should be able to see the properly reflected balance of the requestor address on the target chain for the ported token whose token address is listed in the target_token_address
field. A target_tx_status
of null indicates that the bridge is still working on processing the transaction on the target chain.
Last updated