Skip to main content
Destination payload lets you execute arbitrary contract calls on the destination chain after a crosschain transfer completes. This is useful for flows such as depositing to a vault, repaying a loan, or interacting with a protocol immediately after bridging/swapping.

How it works

When building a Bungee request, you can provide calldata that will be executed on the destination chain. It works for both same chain swaps as well as cross chain swaps. If the below parameters are provided, Bungee will deliver assets on destination and then invoke the receiver contract with your destinationPayload under the specified gas limit.
  • destinationPayload: ABI-encoded calldata for the target contract on the destination chain
  • receiverAddress: The execution target that will receive the calldata and perform the call
  • destinationGasLimit: Gas budget on destination to execute the payload
interface IBungeeExecutor {
    function executeData(
        bytes32 requestHash,
        uint256[] calldata amounts,
        address[] calldata tokens,
        bytes memory callData
    ) external payable;
}

Implementation example

const BUNGEE_API_BASE_URL = "https://public-backend.bungee.exchange";

async function getQuoteWithDestinationPayload() {
  const quoteParams = {
    userAddress: "0xYourUsersAddress",
    originChainId: "8453", // Base
    destinationChainId: "8453", // Base
    inputToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base
    outputToken: "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2", // USDT on Base
    inputAmount: "10000000", // 10 USDC (6 decimals)
    receiverAddress: contractAddress, // contract address that implements executeData
    destinationPayload: "0x1234acbd", // calldata for the contract set on receiverAddress
    destinationGasLimit: "100000", // gas ceiling for destination execution
  };

  const url = `${BUNGEE_API_BASE_URL}/api/v1/bungee/quote`;
  const queryParams = new URLSearchParams(quoteParams);
  const fullUrl = `${url}?${queryParams}`;

  const response = await fetch(fullUrl, {
    method: "GET",
    headers: {
      "Content-Type": "application/json",
    },
  });

  const data = await response.json();
  const serverReqId = response.headers.get("server-req-id");

  if (!data.success) {
    throw new Error(
      `Quote error: ${data.statusCode}: ${data.message}. server-req-id: ${serverReqId}`
    );
  }
}

Important Notes

  • The destinationPayload is the callData parameter that will be passed to the executeData function
  • Execution may fail due to invalid encoding: re-check encodeAbiParameters types match the receiver decode
  • The receiverAddress needs to be a contract that implements IBungeeExecutor contract’s interface for the executeData function
  • Ensure the receiver contract trusts/can handle calls from the Bungee executor
  • Complex receivers or multi-token logic require higher gas limits
  • Execution may fail due to out of gas on destination: increase destinationGasLimit