prepare

Prepares a finalized Universal Bridge quote for the provided buy request with transaction data. This function will return everything quote does, with the addition of a series of prepared transactions and the associated expiration timestamp.

Example

import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
const quote = await Bridge.Buy.prepare({
originChainId: 1,
originTokenAddress: NATIVE_TOKEN_ADDRESS,
destinationChainId: 10,
destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
buyAmountWei: toWei("0.01"),
client: thirdwebClient,
});

This will return a quote that might look like:

{
originAmount: 10000026098875381n,
destinationAmount: 1000000000000000000n,
blockNumber: 22026509n,
timestamp: 1741730936680,
estimatedExecutionTimeMs: 1000
transactions: [
{
to: NATIVE_TOKEN_ADDRESS,
value: 10000026098875381n,
data: "0x",
chainId: 10,
type: "eip1559"
}
],
expiration: 1741730936680,
intent: {
originChainId: 1,
originTokenAddress: NATIVE_TOKEN_ADDRESS,
destinationChainId: 10,
destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
buyAmountWei: 1000000000000000000n
}
}

Sending the transactions

The transactions array is a series of ox EIP-1559 transactions that must be executed one after the other in order to fulfill the complete route. There are a few things to keep in mind when executing these transactions:

  • Approvals and other preparation transactions are not included in the transactions array.

  • All transactions are assumed to be executed by the sender address, regardless of which chain they are on. The final transaction will use the receiver as the recipient address.

  • If an expiration timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.

NOTE: To get the status of each transaction, use Bridge.status rather than checking for transaction inclusion. This function will ensure full bridge completion on the destination chain.

You can access this functions input and output types with Buy.prepare.Options and Buy.prepare.Result , respectively.

function prepare(options: Options): Promise<Result>;

Parameters

The options for the quote.

Type

let options: Options;

Returns

let returnType: Promise<Result>;

A promise that resolves to a non-finalized quote for the requested buy.