Payments

Get Started

thirdweb Payments allow developers to create advanced payment flows to monetize their apps through product sales, peer to peer payments, token sales, and more.

Get started sending payments in your apps with the thirdweb TypeScript SDK.

Installation

Install the thirdweb SDK in your TypeScript project:

npm i thirdweb

Set up the Client

First, create a client instance to connect with thirdweb services:

import { createThirdwebClient } from "thirdweb";
// - clientId for client-side applications
// - secretKey for server-side applications
const client = createThirdwebClient({
clientId: "YOUR_CLIENT_ID", // Get from your thirdweb dashboard
});

Generate a payment

To get started, lets generate a payment for 10 USDC on Optimism, paid with USDT on Arbitrum.

import { Bridge, NATIVE_TOKEN_ADDRESS, toWei } from "thirdweb";
const preparedQuote = await Bridge.Buy.prepare({
originChainId: 42161,
originTokenAddress: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9", // USDT on Arbitrum
destinationChainId: 10,
destinationTokenAddress:
"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85", // USDC on Optimism
amount: 10_000_000n, // 10 USDC in wei (USDC has 6 decimals)
sender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
receiver: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
client,
});

The prepared quote will contain details about the payment, including the transactions needed to execute it.

{
blockNumber: 359092559n,
destinationAmount: 10000000n,
estimatedExecutionTimeMs: 4000,
intent: {
amount: 10000000n,
destinationChainId: 10,
destinationTokenAddress: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
originChainId: 42161,
originTokenAddress: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
receiver: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
sender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709"
},
originAmount: 10090837n,
steps: [
{
originToken: {
chainId: 42161,
address: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
symbol: "USDT",
name: "Tether USD",
decimals: 6,
priceUsd: 1.000466,
iconUri: "https://coin-images.coingecko.com/coins/images/39963/large/usdt.png?1724952731",
prices: {
USD: 1.000466,
EUR: 0.8609646893353334,
// ...more currencies
}
},
destinationToken: {
chainId: 10,
address: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
symbol: "USDC",
name: "USD Coin",
decimals: 6,
priceUsd: 0.999859,
iconUri: "https://ethereum-optimism.github.io/data/USDC/logo.png",
prices: {
USD: 0.999859,
EUR: 0.8604423271896667,
// ...more currencies
}
},
transactions: [
{
chainId: 42161,
to: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
data: "0x095ea7b3000000000000000000000000f8ab2dbe6c43bf1a856471182290f91d621ba76d00000000000000000000000000000000000000000000000000000000009d0695",
type: "eip1559",
id: "0x2354360325ff8315dad5673894207d90c28cb898788025202b6a6f8c2bd8220a",
action: "approval",
chain: {
// ...chain details
},
client: {
clientId: "...",
}
},
{
type: "eip1559",
to: "0xF8Ab2dBE6c43bf1a856471182290f91D621Ba76d",
from: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
value: 0n,
data: "0x...",
chainId: 42161,
action: "buy",
id: "0xc4fd6ecdbbf6fb0780c87779adff09ea7f480fac385b8db4873fc1a0d3309264",
spender: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
chain: {
// ...chain details
},
client: {
clientId: "...",
}
}
],
originAmount: 10090837n,
destinationAmount: 10000000n,
estimatedExecutionTimeMs: 4000
}
],
timestamp: 1752866509083
}

You can execute the included transactions using the wallet of your choice. To learn how to send it using thirdweb Wallets, checkout the Send a Payment guide.

Going further

To connect with other auth strategies, use external wallets, or sponsor gas for users, check out the following guides:

Explore Full API References

For comprehensive guides on implementing the full thirdweb SDK, explore our language-specific documentation: