Orbit Bridge
Search
K

3. How to use an Orbit Bridge

** The chain parameter should have the following format:
ETH, ORBIT, KLAYTN, BSC, MATIC, HECO, CELO, AVAX, FANTOM, HARMONY, MOONRIVER, OEC, XDAI

EVM

Vault Contract Interface

1
interface IVault {
2
function deposit(string memory toChain, bytes memory toAddr) payable public;
3
function depositToken(address token, string memory toChain, bytes memory toAddr, uint amount) public;
4
}
  • You can use the vault to bridge assets to other chains which deployed minter. (ex) Bsc vault has only Klaytn, Orbit, Heco and Matic minter. (See BSC vault contracts) BNB can bridge to Heco. But cannot bridge to Fantom.
  • If you want to bridge native assets like ETH or BNB, use deposit.
  • Otherwise, if you want to bridge ERC20, use depositToken.
  • Orbit Bridge has ETH, KLAYTN, BSC, MATIC, HECO, CELO vaults.

Details

1
deposit(string memory toChain, bytes memory toAddr) payable
  • toChain: Chain symbol to send assets.
  • toAddr: Address to receive bridged assets. ** You must send a transaction with value for the amount to be sent.
1
depositToken(address token, string memory toChain, bytes memory toAddr, uint amount)
  • toChain: Chain symbol to send assets
  • toAddr: Address to receive bridged assets
  • amount: The amounts of tokens to send (wei)

Example

  1. 1.
    Bridge 0.1 ETH from ETH to KLAYTN
1
deposit("KLAYTN", <to address>){value: 100000000000000000}
2. Bridge 10 BUSD from BNB to MATIC
1
depositToken("MATIC", <to address>, 10000000000000000000)

Minter Contract Interface

1
interface IMinter {
2
function getChainId(string chain) external view returns (bytes32);
3
function chainFee(bytes32 chainId) external view returns (uint256);
4
function getTokenAddress(bytes memory token) public view returns(address);
5
function requestSwap(address tokenAddress, string memory toChain, bytes memory toAddr, uint amount) public payable;
6
}
  • You can use the minter to send bridged assets to the origin chain or another chain.
  • In this case, only use requestSwap
  • Depending on the chain, there may be a chain fee.
  • If there is a chain fee, you need to send a transaction by putting it in value.
  • Minted Tokens have the prefix ‘o’ which means bridged by an Orbit Bridge. (oUSDT, oBUSD, oXRP, oETH etc…)

Details

1
getChainId(string chain)
Returns unique bytes32 data for each chain.
  • chain: Chain symbol to send assets.
1
chainFee(bytes32 chainId)
Returns chain fee for each chain.
  • chainId: bytes32 data from getChainId method.
1
getTokenAddress(bytes memory token)
  • token: Address of origin asset. For native assets, it is 0x0000000000000000000000000000000000000000
1
requestSwap(address tokenAddress, string memory toChain, bytes memory toAddr, uint amount)
  • tokenAddress: Returned value using getTokenAddress
  • toChain: Chain symbol to send assets.
  • toAddr: Address to receive bridged assets.
  • amount: The amounts of tokens to send (wei)

Example

  1. 1.
    Bridge 0.1 oETH from KLAYTN to ETH
  • oETH on Klaytn is a bridged ERC20 token from Eth.
  • ETH is a native asset of the Ethereum chain.
  • In this case, use the Klaytn minter contract of Eth vault
1
requestSwap(
2
"0x0000000000000000000000000000000000000000"
3
, "KLAYTN"
4
, <to address>
5
, 100000000000000000 // 0.1 * 10 ** 18
6
){value: 100000000000000000} // chainFee
2. Bridge 10 oBUSD from MATIC to HECO
  • oBUSD on Matic is a bridged ERC20 from BNB chain.
  • BUSD is an ERC20 based on the BNB chain.
  • To bridge oBUSD from Matic to Heco, use Matic minter contract of Bsc vault
1
requestSwap(
2
"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56" // origin BUSD address
3
, "HECO"
4
, <to address>
5
, 10000000000000000000 // 10 * 10 ** 18
6
){value: 100000000000000000} // chainFee

STACKS

Minter Contract Interface

1
(request-swap (to-chain (buff 256)) (to-addr (buff 20)) (amount uint))
In the case of Stacks, there is a minter corresponding to each bridged token.
  • to-chain: Chain to send assets. This value can get using bufferCVFromString (see @stacks/transactions)
  • to-addr: Address to receive bridged assets.