import { Container } from 'react-dom/client'; import { Hex, Address } from 'ox'; declare const currencySymbol: { readonly USD: "$"; readonly EUR: "€"; readonly GBP: "£"; readonly JPY: "¥"; readonly KRW: "₩"; readonly CNY: "¥"; readonly INR: "₹"; readonly NOK: "kr"; readonly SEK: "kr"; readonly CHF: "CHF"; readonly AUD: "$"; readonly CAD: "$"; readonly NZD: "$"; readonly MXN: "$"; readonly BRL: "R$"; readonly CLP: "$"; readonly CZK: "Kč"; readonly DKK: "kr"; readonly HKD: "$"; readonly HUF: "Ft"; readonly IDR: "Rp"; readonly ILS: "₪"; readonly ISK: "kr"; }; type SupportedFiatCurrency = keyof typeof currencySymbol; type PurchaseData = Record; /** * @theme */ type Theme = { type: "light" | "dark"; colors: { primaryText: string; secondaryText: string; accentText: string; danger: string; success: string; modalOverlayBg: string; accentButtonBg: string; accentButtonText: string; primaryButtonBg: string; primaryButtonText: string; secondaryButtonBg: string; secondaryButtonText: string; secondaryButtonHoverBg: string; modalBg: string; tooltipBg: string; tooltipText: string; inputAutofillBg: string; scrollbarBg: string; tertiaryBg: string; separatorLine: string; secondaryIconColor: string; secondaryIconHoverBg: string; secondaryIconHoverColor: string; borderColor: string; skeletonBg: string; selectedTextColor: string; selectedTextBg: string; connectedButtonBg: string; connectedButtonBgHover: string; }; fontFamily: string; }; /** * @theme */ type ThemeOverrides = { [key in Exclude]?: Partial; }; /** * Combines members of an intersection into a readable type. * @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg} * @example * Prettify<{ a: string } & { b: string } & { c: number, d: bigint }> * => { a: string, b: string, c: number, d: bigint } */ type Prettify = { [K in keyof T]: T[K]; } & {}; type FetchConfig = { requestTimeoutMs?: number; keepalive?: boolean; headers?: HeadersInit; }; type ClientOptions = Prettify<{ /** * The configuration options for the client. */ config?: { /** * The configuration options for the RPC client. */ rpc?: { /** * The configuration options for the fetch function. * @default {} */ fetch?: FetchConfig; /** * The maximum number of requests to batch together. * @default 100 */ maxBatchSize?: number; /** * The maximum time to wait before sending a batch of requests. * @default 0 (no timeout) */ batchTimeoutMs?: number; }; /** * The configuration options for the storage client. */ storage?: { /** * The configuration options for the fetch function. * @default {} */ fetch?: FetchConfig; /** * The IPFS gateway URL. * @default "https://.ipfscdn.io/ipfs/" */ gatewayUrl?: string; }; }; /** * The team ID for thirdweb dashboard usage. * @hidden */ teamId?: string; }>; type ThirdwebClient = { readonly clientId: string; readonly secretKey: string | undefined; } & Readonly; /** * Retrieves the status of an Onramp session created via {@link Bridge.Onramp.prepare}. The * status will include any on-chain transactions that have occurred as a result of the onramp * as well as any arbitrary `purchaseData` that was supplied when the onramp was * prepared. * * @example * ```typescript * import { Bridge } from "thirdweb"; * * const onrampStatus = await Bridge.Onramp.status({ * id: "022218cc-96af-4291-b90c-dadcb47571ec", * client: thirdwebClient, * }); * * // Possible results: * // { * // status: "CREATED", * // transactions: [], * // purchaseData: { * // orderId: "abc-123", * // }, * // } * // * // or * // { * // status: "PENDING", * // transactions: [], * // purchaseData: { * // orderId: "abc-123", * // }, * // } * // * // or * // { * // status: "COMPLETED", * // transactions: [ * // { * // chainId: 1, * // transactionHash: * // "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", * // }, * // ], * // purchaseData: { * // orderId: "abc-123", * // }, * // } * ``` * * @param options - The options for fetching the onramp status. * @param options.id - The UUID returned from {@link Bridge.Onramp.prepare}. * @param options.client - Your thirdweb client instance. * * @returns A promise that resolves to the status of the onramp session. * * @throws Will throw an error if there is an issue fetching the status. * @bridge Onramp * @beta */ declare function status(options: status.Options): Promise; declare namespace status { /** * Input parameters for {@link Bridge.Onramp.status}. */ type Options = { /** * The Onramp session ID returned by {@link Bridge.Onramp.prepare}. */ id: string; /** Your {@link ThirdwebClient} instance. */ client: ThirdwebClient; }; /** * The result returned from {@link Bridge.Onramp.status}. */ type Result = { status: "COMPLETED"; transactions: Array<{ chainId: number; transactionHash: Hex.Hex; }>; purchaseData?: PurchaseData; } | { status: "PENDING"; transactions: Array<{ chainId: number; transactionHash: Hex.Hex; }>; purchaseData?: PurchaseData; } | { status: "CREATED"; transactions: Array<{ chainId: number; transactionHash: Hex.Hex; }>; purchaseData?: PurchaseData; } | { status: "FAILED"; transactions: Array<{ chainId: number; transactionHash: Hex.Hex; }>; purchaseData?: PurchaseData; }; } type FeeType = "legacy" | "eip1559"; /** * @chain */ type Chain = Readonly; /** * @chain */ type ChainOptions = { id: number; name?: string; rpc?: string; icon?: Icon; nativeCurrency?: { name?: string; symbol?: string; decimals?: number; }; blockExplorers?: Array<{ name: string; url: string; apiUrl?: string; }>; testnet?: true; experimental?: { increaseZeroByteCount?: boolean; }; faucets?: Array; feeType?: FeeType; }; /** * @chain */ type Icon = { url: string; width: number; height: number; format: string; }; type Action = "approval" | "transfer" | "buy" | "sell" | "fee"; type Token = { chainId: number; address: Address.Address; decimals: number; symbol: string; name: string; iconUri?: string; marketCapUsd?: number; volume24hUsd?: number; }; type TokenWithPrices = Token & { prices: Record; }; type RouteStep = { originToken: TokenWithPrices; destinationToken: TokenWithPrices; originAmount: bigint; destinationAmount: bigint; estimatedExecutionTimeMs: number; transactions: RouteTransaction[]; }; type RouteTransaction = { data: Hex.Hex; to: Hex.Hex; value?: bigint | undefined; chainId: number; /** * The action this transaction performs. This can be "approval", "transfer", "buy", or "sell". */ action: Action; /** * The transaction ID, used for tracking purposes. */ id: Hex.Hex; client: ThirdwebClient; chain: Chain; }; type Status = { status: "COMPLETED"; paymentId: string; originAmount: bigint; destinationAmount: bigint; originChainId: number; destinationChainId: number; originTokenAddress: Address.Address; destinationTokenAddress: Address.Address; originToken: Token; destinationToken: Token; sender: Address.Address; receiver: Address.Address; transactions: Array<{ chainId: number; transactionHash: Hex.Hex; }>; purchaseData?: PurchaseData; } | { status: "PENDING"; paymentId: string; originAmount: bigint; originChainId: number; destinationChainId: number; originTokenAddress: Address.Address; destinationTokenAddress: Address.Address; originToken: Token; destinationToken: Token; sender: Address.Address; receiver: Address.Address; transactions: Array<{ chainId: number; transactionHash: Hex.Hex; }>; purchaseData?: PurchaseData; } | { status: "FAILED"; paymentId: string; transactions: Array<{ chainId: number; transactionHash: Hex.Hex; }>; purchaseData?: PurchaseData; } | { status: "NOT_FOUND"; paymentId: string; transactions: []; }; type PreparedQuote = { /** * The input amount (in wei) including fees to be paid. */ originAmount: bigint; /** * The output amount (in wei) to be received. */ destinationAmount: bigint; /** * The blocknumber this quote was generated at. */ blockNumber?: bigint; /** * The timestamp this quote was generated at. */ timestamp: number; /** * The estimated execution time in milliseconds. */ estimatedExecutionTimeMs?: number | undefined; /** * The expiration timestamp for the quote. All transactions must be executed before this timestamp to guarantee successful execution at the specified price. */ expiration?: number | undefined; /** * A series of steps required to complete the quote, along with the transactions to execute in order. */ steps: RouteStep[]; }; /** * Prepares a **finalized** 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 * ```typescript * 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, * amount: toWei("0.01"), * sender: "0x...", * receiver: "0x...", * client: thirdwebClient, * }); * ``` * * This will return a quote that might look like: * ```typescript * { * originAmount: 2000030000n, * destinationAmount: 1000000000000000000n, * blockNumber: 22026509n, * timestamp: 1741730936680, * estimatedExecutionTimeMs: 1000 * steps: [ * { * originToken: { * chainId: 1, * address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", * symbol: "USDC", * name: "USDC", * decimals: 6, * priceUsd: 1, * iconUri: "https://..." * }, * destinationToken: { * chainId: 10, * address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", * symbol: "ETH", * name: "Ethereum", * decimals: 18, * priceUsd: 2000, * iconUri: "https://..." * }, * originAmount: 2000030000n, * destinationAmount: 1000000000000000000n, * estimatedExecutionTimeMs: 1000 * transactions: [ * { * action: "approval", * id: "0x", * to: "0x...", * data: "0x...", * chainId: 10, * type: "eip1559" * }, * { * action: "buy", * to: "0x...", * value: 10000026098875381n, * data: "0x...", * chainId: 10, * type: "eip1559" * } * ] * } * ], * expiration: 1741730936680, * intent: { * originChainId: 1, * originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", * destinationChainId: 10, * destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", * amount: 1000000000000000000n * } * } * ``` * * ## Sending the transactions * The `transactions` array is a series of transactions ready to be executed (with `sendTransaction`) 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 will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction. * - 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 non-approval 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. * * You can include arbitrary data to be included on any webhooks and status responses with the `purchaseData` option. * * ```ts * const quote = await Bridge.Buy.prepare({ * originChainId: 1, * originTokenAddress: NATIVE_TOKEN_ADDRESS, * destinationChainId: 10, * destinationTokenAddress: NATIVE_TOKEN_ADDRESS, * amount: toWei("0.01"), * sender: "0x...", * receiver: "0x...", * purchaseData: { * size: "large", * shippingAddress: "123 Main St, New York, NY 10001", * }, * client: thirdwebClient, * }); * ``` * * To limit quotes to routes that have a certain number of steps involved, use the `maxSteps` option. * * ```ts * const quote = await Bridge.Buy.prepare({ * originChainId: 1, * originTokenAddress: NATIVE_TOKEN_ADDRESS, * destinationChainId: 10, * destinationTokenAddress: NATIVE_TOKEN_ADDRESS, * amount: toWei("0.01"), * sender: "0x...", * receiver: "0x...", * maxSteps: 2, // Will only return a quote for routes with 2 or fewer steps * client: thirdwebClient, * }); * ``` * * @param options - The options for the quote. * @param options.originChainId - The chain ID of the origin token. * @param options.originTokenAddress - The address of the origin token. * @param options.destinationChainId - The chain ID of the destination token. * @param options.destinationTokenAddress - The address of the destination token. * @param options.amount - The amount of the destination token to receive. * @param options.sender - The address of the sender. * @param options.receiver - The address of the recipient. * @param [options.purchaseData] - Arbitrary data to be passed to the purchase function and included with any webhooks or status calls. * @param [options.maxSteps] - Limit the number of total steps in the route. * @param options.client - Your thirdweb client. * * @returns A promise that resolves to a finalized quote and transactions for the requested buy. * * @throws Will throw an error if there is an issue fetching the quote. * @bridge Buy */ declare function prepare$3(options: prepare$3.Options): Promise; /** * Namespace containing types for the buy prepare function. * @namespace prepare * @bridge Buy */ declare namespace prepare$3 { /** * Options for preparing a buy transaction. * @interface Options * @bridge Buy */ type Options = { /** The origin chain ID */ originChainId: number; /** The origin token address */ originTokenAddress: Address.Address; /** The destination chain ID */ destinationChainId: number; /** The destination token address */ destinationTokenAddress: Address.Address; /** The sender address */ sender: Address.Address; /** The receiver address */ receiver: Address.Address; /** The amount to buy in wei */ amount: bigint; /** Your thirdweb client */ client: ThirdwebClient; /** Arbitrary purchase data */ purchaseData?: PurchaseData; /** Maximum number of steps in the route */ maxSteps?: number; /** The maximum slippage in basis points (bps) allowed for the transaction. */ slippageToleranceBps?: number; /** * @hidden */ paymentLinkId?: string; }; /** * Result returned from preparing a buy transaction. * Contains prepared quote with transaction data and intent information. * @interface Result * @bridge Buy */ type Result = PreparedQuote & { intent: { originChainId: number; originTokenAddress: Address.Address; destinationChainId: number; destinationTokenAddress: Address.Address; amount: bigint; sender: Address.Address; receiver: Address.Address; purchaseData?: PurchaseData; }; }; } type OnrampIntent = { onramp: "stripe" | "coinbase" | "transak"; chainId: number; tokenAddress: Address.Address; receiver: Address.Address; amount?: string; purchaseData?: PurchaseData; sender?: Address.Address; onrampTokenAddress?: Address.Address; onrampChainId?: number; currency?: string; maxSteps?: number; excludeChainIds?: string | string[]; }; type OnrampPrepareQuoteResponseData = { id: string; link: string; currency: string; currencyAmount: number; destinationAmount: bigint; destinationToken: TokenWithPrices; timestamp?: number; expiration?: number; steps: RouteStep[]; intent: OnrampIntent; }; /** * Prepares an onramp transaction, returning a link from the specified provider to onramp to the specified token. * * @example * ```typescript * import { Bridge } from "thirdweb"; * import { ethereum } from "thirdweb/chains"; * import { NATIVE_TOKEN_ADDRESS, toWei } from "thirdweb/utils"; * * const preparedOnramp = await Bridge.Onramp.prepare({ * client: thirdwebClient, * onramp: "stripe", * chainId: ethereum.id, * tokenAddress: NATIVE_TOKEN_ADDRESS, * receiver: "0x...", // receiver's address * amount: toWei("10"), // 10 of the destination token * // Optional params: * // sender: "0x...", // sender's address * // onrampTokenAddress: NATIVE_TOKEN_ADDRESS, // token to initially onramp to * // onrampChainId: 1, // chain to initially onramp to * // currency: "USD", * // maxSteps: 2, * // purchaseData: { customId: "123" } * }); * * console.log(preparedOnramp.link); // URL to redirect the user to * console.log(preparedOnramp.currencyAmount); // Amount in fiat the user will pay * ``` * * This function returns a quote that might look like: * ```typescript * { * id: "123e4567-e89b-12d3-a456-426614174000", * link: "https://onramp.example.com/session?id=...", * currency: "USD", * currencyAmount: 10.52, * destinationAmount: 10000000000000000000n, // 10 ETH if decimals 18 * timestamp: 1689812800, * expiration: 1689842800, * steps: [ * // ... further steps if any post-onramp swaps are needed * ], * intent: { * onramp: "stripe", * chainId: 1, * tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", * receiver: "0x...", * amount: "10000000000000000000" * } * } * ``` * * ### Global Support * * For the best user experience, specify the user's `country` code in your request. This will return an error if the user's country is not supported by the provider. * * ```typescript * const preparedOnramp = await Bridge.Onramp.prepare({ * client: thirdwebClient, * onramp: "stripe", * chainId: ethereum.id, * tokenAddress: NATIVE_TOKEN_ADDRESS, * receiver: "0x...", // receiver's address * amount: toWei("10"), // 10 of the destination token * country: "AU" // User's country code * }); * ``` * * @param options - The options for preparing the onramp. * @param options.client - Your thirdweb client. * @param options.onramp - The onramp provider to use (e.g., "stripe", "coinbase", "transak"). * @param options.chainId - The destination chain ID. * @param options.tokenAddress - The destination token address. * @param options.receiver - The address that will receive the output token. * @param [options.amount] - The desired token amount in wei. * @param [options.purchaseData] - Arbitrary purchase data. * @param [options.sender] - An optional address to associate as the onramp sender. * @param [options.onrampTokenAddress] - The token to initially onramp to if the destination token is not supported by the provider. * @param [options.onrampChainId] - The chain ID to initially onramp to if the destination chain is not supported. * @param [options.currency] - The currency for the onramp (e.g., "USD", "GBP"). Defaults to user's preferred or "USD". * @param [options.maxSteps] - Maximum number of post-onramp steps. * @param [options.excludeChainIds] - Chain IDs to exclude from the route (string or array of strings). * @param [options.country] - The user's country code (e.g. "US", "JP"). Defaults to "US". We highly recommend this be set (based on the user's IP address). * * @returns A promise that resolves to the prepared onramp details, including the link and quote. * @throws Will throw an error if there is an issue preparing the onramp. * @bridge Onramp * @beta */ declare function prepare$2(options: prepare$2.Options): Promise; /** * Namespace containing types for the onramp prepare function. * @namespace prepare * @bridge Onramp */ declare namespace prepare$2 { /** * Options for preparing an onramp transaction. * @interface Options * @bridge Onramp */ type Options = { /** Your thirdweb client */ client: ThirdwebClient; /** The onramp provider to use (e.g., "stripe", "coinbase", "transak") */ onramp: "stripe" | "coinbase" | "transak"; /** The destination chain ID */ chainId: number; /** The destination token address */ tokenAddress: Address.Address; /** The address that will receive the output token */ receiver: Address.Address; /** The desired token amount in wei */ amount?: bigint; /** Arbitrary purchase data */ purchaseData?: PurchaseData; /** An optional address to associate as the onramp sender */ sender?: Address.Address; /** The token to initially onramp to if the destination token is not supported by the provider */ onrampTokenAddress?: Address.Address; /** The chain ID to initially onramp to if the destination chain is not supported */ onrampChainId?: number; /** The currency for the onramp (e.g., "USD", "GBP"). Defaults to user's preferred or "USD" */ currency?: string; /** Maximum number of post-onramp steps */ maxSteps?: number; /** Chain IDs to exclude from the route (string or array of strings) */ excludeChainIds?: string | string[]; /** The user's country code (e.g. "US", "JP"). Defaults to "US". We highly recommend this be set (based on the user's IP address) */ country?: string; /** * @hidden */ paymentLinkId?: string; }; /** * Result returned from preparing an onramp transaction. * Contains the onramp link, quote information, and routing steps. * @interface Result * @bridge Onramp */ type Result = OnrampPrepareQuoteResponseData; } /** * Prepares a **finalized** Bridge quote for the provided sell 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 * ```typescript * import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb"; * * const quote = await Bridge.Sell.prepare({ * originChainId: 1, * originTokenAddress: NATIVE_TOKEN_ADDRESS, * destinationChainId: 10, * destinationTokenAddress: NATIVE_TOKEN_ADDRESS, * amount: toWei("0.01"), * client: thirdwebClient, * }); * ``` * * This will return a quote that might look like: * ```typescript * { * originAmount: 2000000000n, * destinationAmount: 9980000000000000000n, * blockNumber: 22026509n, * timestamp: 1741730936680, * estimatedExecutionTimeMs: 1000 * steps: [ * { * originToken: { * chainId: 1, * address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", * symbol: "USDC", * name: "USDC", * decimals: 6, * priceUsd: 1, * iconUri: "https://..." * }, * destinationToken: { * chainId: 10, * address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", * symbol: "ETH", * name: "Ethereum", * decimals: 18, * priceUsd: 2000, * iconUri: "https://..." * }, * originAmount: 2000000000n, * destinationAmount: 9980000000000000000n, * estimatedExecutionTimeMs: 1000 * } * transactions: [ * { * id: "0x...", * action: "approval", * to: "0x...", * data: "0x...", * chainId: 10, * type: "eip1559" * }, * { * id: "0x...", * action: "sell", * to: "0x...", * data: "0x...", * chainId: 10, * type: "eip1559" * } * ], * ], * expiration: 1741730936680, * intent: { * originChainId: 1, * originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", * destinationChainId: 10, * destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", * amount: 2000000000n * } * } * ``` * * ## Sending the transactions * The `transactions` array is a series of transactions ready to be executed (with `sendTransaction`) 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 will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction. * - 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 non-approval 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 `Sell.prepare.Options` and `Sell.prepare.Result`, respectively. * * You can include arbitrary data to be included on any webhooks and status responses with the `purchaseData` option. * * ```ts * const quote = await Bridge.Sell.prepare({ * originChainId: 1, * originTokenAddress: NATIVE_TOKEN_ADDRESS, * destinationChainId: 10, * destinationTokenAddress: NATIVE_TOKEN_ADDRESS, * amount: toWei("0.01"), * purchaseData: { * size: "large", * shippingAddress: "123 Main St, New York, NY 10001", * }, * client: thirdwebClient, * }); * ``` * * To limit quotes to routes that have a certain number of steps involved, use the `maxSteps` option. * * ```ts * const quote = await Bridge.Sell.prepare({ * originChainId: 1, * originTokenAddress: NATIVE_TOKEN_ADDRESS, * destinationChainId: 10, * destinationTokenAddress: NATIVE_TOKEN_ADDRESS, * amount: toWei("0.01"), * maxSteps: 2, // Will only return a quote for routes with 2 or fewer steps * client: thirdwebClient, * }); * ``` * * @param options - The options for the quote. * @param options.originChainId - The chain ID of the origin token. * @param options.originTokenAddress - The address of the origin token. * @param options.destinationChainId - The chain ID of the destination token. * @param options.destinationTokenAddress - The address of the destination token. * @param options.amount - The amount of the origin token to sell. * @param options.sender - The address of the sender. * @param options.receiver - The address of the recipient. * @param options.purchaseData - Arbitrary data to be passed to the purchase function and included with any webhooks or status calls. * @param [options.maxSteps] - Limit the number of total steps in the route. * @param options.client - Your thirdweb client. * * @returns A promise that resolves to a finalized quote and transactions for the requested sell. * * @throws Will throw an error if there is an issue fetching the quote. * @bridge Sell * @beta */ declare function prepare$1(options: prepare$1.Options): Promise; /** * Namespace containing types for the sell prepare function. * @namespace prepare * @bridge Sell */ declare namespace prepare$1 { /** * Options for preparing a sell transaction. * @interface Options * @bridge Sell */ type Options = { /** The origin chain ID */ originChainId: number; /** The origin token address */ originTokenAddress: Address.Address; /** The destination chain ID */ destinationChainId: number; /** The destination token address */ destinationTokenAddress: Address.Address; /** The amount to sell in wei */ amount: bigint; /** The sender address */ sender: Address.Address; /** The receiver address */ receiver: Address.Address; /** Your thirdweb client */ client: ThirdwebClient; /** Arbitrary purchase data */ purchaseData?: PurchaseData; /** Maximum number of steps in the route */ maxSteps?: number; /** The maximum slippage in basis points (bps) allowed for the transaction. */ slippageToleranceBps?: number; /** * @hidden */ paymentLinkId?: string; }; /** * Result returned from preparing a sell transaction. * Contains prepared quote with transaction data and intent information. * @interface Result * @bridge Sell */ type Result = PreparedQuote & { intent: { originChainId: number; originTokenAddress: Address.Address; destinationChainId: number; destinationTokenAddress: Address.Address; amount: bigint; sender: Address.Address; receiver: Address.Address; purchaseData?: PurchaseData; }; }; } /** * Prepares a **finalized** Bridge quote for the provided transfer request with transaction data. * * @example * ```typescript * import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb"; * * const quote = await Bridge.Transfer.prepare({ * chainId: 1, * tokenAddress: NATIVE_TOKEN_ADDRESS, * amount: toWei("0.01"), * sender: "0x...", * receiver: "0x...", * client: thirdwebClient, * }); * ``` * * This will return a quote that might look like: * ```typescript * { * originAmount: 10000026098875381n, * destinationAmount: 10000000000000000n, * blockNumber: 22026509n, * timestamp: 1741730936680, * estimatedExecutionTimeMs: 1000 * steps: [ * { * originToken: { * chainId: 1, * address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", * symbol: "ETH", * name: "Ethereum", * decimals: 18, * priceUsd: 2000, * iconUri: "https://..." * }, * destinationToken: { * chainId: 1, * address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", * symbol: "ETH", * name: "Ethereum", * decimals: 18, * priceUsd: 2000, * iconUri: "https://..." * }, * originAmount: 10000026098875381n, * destinationAmount: 10000000000000000n, * estimatedExecutionTimeMs: 1000 * transactions: [ * { * action: "approval", * id: "0x", * to: "0x...", * data: "0x...", * chainId: 1, * type: "eip1559" * }, * { * action: "transfer", * to: "0x...", * value: 10000026098875381n, * data: "0x...", * chainId: 1, * type: "eip1559" * } * ] * } * ], * expiration: 1741730936680, * intent: { * chainId: 1, * tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", * amount: 10000000000000000n, * sender: "0x...", * receiver: "0x..." * } * } * ``` * * ## Sending the transactions * The `transactions` array is a series of [ox](https://oxlib.sh) 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 will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction. * - 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 non-approval transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full completion of the transfer. * * You can access this functions input and output types with `Transfer.prepare.Options` and `Transfer.prepare.Result`, respectively. * * You can include arbitrary data to be included on any webhooks and status responses with the `purchaseData` option. * * ```ts * const quote = await Bridge.Transfer.prepare({ * chainId: 1, * tokenAddress: NATIVE_TOKEN_ADDRESS, * amount: toWei("0.01"), * sender: "0x...", * receiver: "0x...", * purchaseData: { * reference: "payment-123", * metadata: { * note: "Transfer to Alice" * } * }, * client: thirdwebClient, * }); * ``` * * ## Fees * There may be fees associated with the transfer. These fees are paid by the `feePayer` address, which defaults to the `sender` address. You can specify a different address with the `feePayer` option. If you do not specify an option or explicitly specify `sender`, the fees will be added to the input amount. If you specify the `receiver` as the fee payer the fees will be subtracted from the destination amount. * * For example, if you were to request a transfer with `feePayer` set to `receiver`: * ```typescript * const quote = await Bridge.Transfer.prepare({ * chainId: 1, * tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC * amount: 100_000_000n, // 100 USDC * sender: "0x...", * receiver: "0x...", * feePayer: "receiver", * client: thirdwebClient, * }); * ``` * * The returned quote might look like: * ```typescript * { * originAmount: 100_000_000n, // 100 USDC * destinationAmount: 99_970_000n, // 99.97 USDC * ... * } * ``` * * If you were to request a transfer with `feePayer` set to `sender`: * ```typescript * const quote = await Bridge.Transfer.prepare({ * chainId: 1, * tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC * amount: 100_000_000n, // 100 USDC * sender: "0x...", * receiver: "0x...", * feePayer: "sender", * client: thirdwebClient, * }); * ``` * * The returned quote might look like: * ```typescript * { * originAmount: 100_030_000n, // 100.03 USDC * destinationAmount: 100_000_000n, // 100 USDC * ... * } * ``` * * @param options - The options for the quote. * @param options.chainId - The chain ID of the token. * @param options.tokenAddress - The address of the token. * @param options.amount - The amount of the token to transfer. * @param options.sender - The address of the sender. * @param options.receiver - The address of the recipient. * @param options.purchaseData - Arbitrary data to be passed to the transfer function and included with any webhooks or status calls. * @param options.client - Your thirdweb client. * @param [options.feePayer] - The address that will pay the fees for the transfer. If not specified, the sender will be used. Values can be "sender" or "receiver". * * @returns A promise that resolves to a finalized quote and transactions for the requested transfer. * * @throws Will throw an error if there is an issue fetching the quote. * @bridge Transfer * @beta */ declare function prepare(options: prepare.Options): Promise; /** * Namespace containing types for the transfer prepare function. * @namespace prepare * @bridge Transfer */ declare namespace prepare { /** * Options for preparing a transfer transaction. * @interface Options * @bridge Transfer */ type Options = { /** The chain ID */ chainId: number; /** The token address */ tokenAddress: Address.Address; /** The sender address */ sender: Address.Address; /** The receiver address */ receiver: Address.Address; /** The amount to transfer in wei */ amount: bigint; /** Your thirdweb client */ client: ThirdwebClient; /** Arbitrary purchase data */ purchaseData?: PurchaseData; /** Who pays the fees - sender or receiver */ feePayer?: "sender" | "receiver"; /** * @hidden */ paymentLinkId?: string; }; /** * Result returned from preparing a transfer transaction. * Contains prepared quote with transaction data and intent information. * @interface Result * @bridge Transfer */ type Result = PreparedQuote & { intent: { chainId: number; tokenAddress: Address.Address; amount: bigint; sender: Address.Address; receiver: Address.Address; purchaseData?: PurchaseData; feePayer?: "sender" | "receiver"; }; }; } /** * Union type for different Bridge prepare result types */ type BridgePrepareResult = ({ type: "buy"; } & prepare$3.Result) | ({ type: "sell"; } & prepare$1.Result) | ({ type: "transfer"; } & prepare.Result) | ({ type: "onramp"; } & prepare$2.Result); /** * Type for completed status results from Bridge.status and Onramp.status */ type CompletedStatusResult = ({ type: "buy"; } & Extract) | ({ type: "sell"; } & Extract) | ({ type: "transfer"; } & Extract) | ({ type: "onramp"; } & Extract); type BuyOrOnrampPrepareResult = Extract; type SwapPreparedQuote = Extract; type BridgeWidgetScriptProps = { clientId: string; theme?: "light" | "dark" | ({ type: "light" | "dark"; } & ThemeOverrides); showThirdwebBranding?: boolean; currency?: SupportedFiatCurrency; swap?: { className?: string; style?: React.CSSProperties; onSuccess?: (data: { quote: SwapPreparedQuote; statuses: CompletedStatusResult[]; }) => void; onError?: (error: Error, quote: SwapPreparedQuote) => void; onCancel?: (quote: SwapPreparedQuote) => void; onDisconnect?: () => void; persistTokenSelections?: boolean; prefill?: { buyToken?: { tokenAddress?: string; chainId: number; amount?: string; }; sellToken?: { tokenAddress?: string; chainId: number; amount?: string; }; }; }; buy?: { amount?: string; chainId?: number; tokenAddress?: string; buttonLabel?: string; onCancel?: (quote: BuyOrOnrampPrepareResult | undefined) => void; onError?: (error: Error, quote: BuyOrOnrampPrepareResult | undefined) => void; onSuccess?: (data: { quote: BuyOrOnrampPrepareResult; statuses: CompletedStatusResult[]; }) => void; className?: string; country?: string; presetOptions?: [number, number, number]; purchaseData?: PurchaseData; }; }; declare function render(element: Container, props: BridgeWidgetScriptProps): void; export { render };