Create Bridge Order

Create Bridge Order feature is pivotal for executing the bridging operation. It processes essential inputs such as source and destination chains, asset, amount, and the sender and receiver wallet addresses. This functionality is the core of the bridging service, enabling the actual transfer of assets from one blockchain network to another. By handling these key parameters, it ensures a smooth and efficient transaction, encapsulating the essence of the service's capability to facilitate cross-chain asset movements.

Executes bridge of specified asset from user wallet on source chain to user specified wallet on destination chain.

POST /api/bridge/execute

Headers

Request Body

{
    "transaction_id": "string",
    "hot_wallet_address": "string"
}

Here is the code snippet that demonstrates how to call bridge execution transaction:

//..

const sourceChain= 'ZKSYNC';
const destinationChain= 'ARBITRUM';
const asset = 'USDT';
const amount = '254.33'; 
const senderWallet = '0x'; 
const receiverWallet= '0x'; 
const API_KEY = 'YOUR_API_KEY';

const executeBridge = async (
    sourceChain: string,
    destinationChain: string,
    asset: string,
    amount: string,
    senderWallet: string,
    receiverWallet: string,
    sourceNetworkType: string,
    walletCookie?: string[],
  ) => {
    const url = `/api/bridge/execute`;

    const data = {
      source_chain: sourceChain,
      destination_chain: destinationChain,
      asset: asset,
      amount: amount,
      sender_wallet: senderWallet,
      receiver_wallet: receiverWallet,
    };

    const res = await axios.post(url, data, {
      headers: {
        ["api-key"]: API_KEY,
        ["network-type"]: sourceNetworkType,
        cookie: walletCookie,
      },
    });

    return res;
  }

const bridge = async (
    amount: string,
    sourceNetworkType: string,
  ) => {
    const cookies = walletCookies[senderWallet];

    if (!walletCookies) {
      throw new Error(`Cookies for wallet: ${senderWallet} don't exist`);
    }

    const bridgeData = await executeBridge(
      sourceChain,
      destinationChain,
      asset,
      amount,
      senderWallet,
      receiverWallet,
      sourceNetworkType,
      cookies,
    );

   const transactionId = bridgeData.transaction_id;
   const hotWalletAddress = bridgeData.hot_wallet_address;
   //..
}

//..

Once bridge transaction has been sent to API, backend constantly monitors it's Hot wallet transactions on source chain to track incoming assets movement from the user wallet. In order to make process completed on-chain transfer transaction should be sent to Hot wallet on source chain.

Last updated