Releases: thirdweb-dev/js
[email protected]
Patch Changes
-
#7119
dcd6b99
Thanks @joaquim-verges! - Better error messages in PayEmbed -
#7090
1e0b142
Thanks @joaquim-verges! - Allow limiting the selectable countries for SMS login via a newallowedSmsCountryCodes
option placed alongsidedefaultSmsCountryCode
. -
#7123
f31116e
Thanks @jnsdls! - fix avatar image detection on Node -
#7110
7b72e88
Thanks @RobbyUitbeijerse! - Fix loading spinner theme color in PayEmbed -
#7108
dd2fb1b
Thanks @RobbyUitbeijerse! - Add support for filtering fiat payment providers in PayEmbed -
#7121
376bdb2
Thanks @gregfromstl! - Payment link support in PayEmbed -
#7145
69fdef0
Thanks @joaquim-verges! - Ensure bigints are stringified before usage with server wallets
@thirdweb-dev/[email protected]
@thirdweb-dev/[email protected]
@thirdweb-dev/[email protected]
@thirdweb-dev/[email protected]
@thirdweb-dev/[email protected]
Patch Changes
- #7114
4b9a506
Thanks @joaquim-verges! - Better error messages for 403 responses
[email protected]
Patch Changes
- #7104
30fafd1
Thanks @joaquim-verges! - Fix siwe auth always forcing a switch chain call
@thirdweb-dev/[email protected]
@thirdweb-dev/[email protected]
[email protected]
Minor Changes
-
#7064
64964da
Thanks @gregfromstl! - Adds Bridge.Transfer module for direct token transfers: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:
{ 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 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 withsendAndConfirmTransaction
, 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 thereceiver
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 include arbitrary data to be included on any webhooks and status responses with the
purchaseData
option: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 thesender
address. You can specify a different address with thefeePayer
option. If you do not specify an option or explicitly specifysender
, the fees will be added to the input amount. If you specify thereceiver
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 toreceiver
: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:
{ originAmount: 100_000_000n, // 100 USDC destinationAmount: 99_970_000n, // 99.97 USDC ... }
If you were to request a transfer with
feePayer
set tosender
: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:
{ originAmount: 100_030_000n, // 100.03 USDC destinationAmount: 100_000_000n, // 100 USDC ... }
- Approvals will have the
Patch Changes
-
#7064
64964da
Thanks @gregfromstl! - Faster useSendTransaction execution -
#7092
d623978
Thanks @joaquim-verges! - Show deposit modal for tokens that don't have any UB routes -
#7076
89ccc80
Thanks @joaquim-verges! - Added Bridge.Onramp.prepare and Bridge.Onramp.status functionsBridge.Onramp.prepare
Prepares an onramp transaction, returning a link from the specified provider to onramp to the specified token.
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); // Price in fiat currency
Bridge.Onramp.status
Retrieves the status of an Onramp session created via Bridge.Onramp.prepare.
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", // }, // }
@thirdweb-dev/[email protected]
@thirdweb-dev/[email protected]
[email protected]
Patch Changes
- #7077
c61e258
Thanks @joaquim-verges! - expose getInstalledWallets() utility
@thirdweb-dev/[email protected]
@thirdweb-dev/[email protected]