Direct transfer to hot-wallet from user address

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

//..

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

const executeBridge = async (
    source_chain: string,
    destination_chain: string,
    asset_from: string,
    asset_to: 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_from: asset_from,
      asset_to: asset_to,
      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,
      assetFrom,
      assetTo,
      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