Releases: thirdweb-dev/js
@thirdweb-dev/chains@0.1.93
Patch Changes
- #2746
bf6a8e0
Thanks @github-actions! - Synced Chains Package
@thirdweb-dev/auth@4.1.60
Patch Changes
- Updated dependencies [
cb2a7e9
]:- @thirdweb-dev/wallets@2.5.2
thirdweb@5.4.2
Patch Changes
- #2579
d836889
Thanks @ElasticBottle! - ExportresolvePromisedValue
fromthirdweb/utils
@thirdweb-dev/wallets@2.5.1
@thirdweb-dev/unity-js-bridge@0.6.10
@thirdweb-dev/sdk@4.0.61
Patch Changes
-
#2579
d836889
Thanks @ElasticBottle! - Adds "buy with crypto" APIs, Here's an example of how you can use it for swapping tokens// 1. get a quote for swapping tokens const quote = await getBuyWithCryptoQuote(quoteParams); // 2. if approval is required, send the approval transaction if (quote.approval) { const approvalTx = await signer.sendTransaction(quote.approval); await approvalTx.wait(); } // 3. send the quoted transaction const buyTx = await signer.sendTransaction(quote.transactionRequest); await buyTx.wait(); // 4. keep polling the status of the quoted transaction until it * returns a success or failure status const status = await getBuyWithCryptoStatus({ clientId: "YOUR_CLIENT_ID", transactionHash: transactionResult.hash, });
For more information, check out the pay documentation for purchases with crypto
-
Updated dependencies [
d836889
,d65713a
]:- thirdweb@5.4.2
- @thirdweb-dev/chains@0.1.92
@thirdweb-dev/react@4.6.0
Minor Changes
-
#2579
d836889
Thanks @ElasticBottle! - AddsBuy
button inConnectWallet
component's details Modal to allow users to Swap tokens. SettingclientId
onThirdWebProvider
is required to enable this feature.A new prop
hideBuyButton
is added toConnectWallet
component to hide theBuy
button in the details Modal. By default, theBuy
button is visible.
Patch Changes
@thirdweb-dev/react-native@0.7.32
@thirdweb-dev/react-native-compat@0.7.32
@thirdweb-dev/react-native-compat@0.7.32
@thirdweb-dev/react-core@4.6.0
Minor Changes
-
#2579
d836889
Thanks @ElasticBottle! - Adds "buy with crypto" Hooks, Here's an example of how you can use it to build a UI for Swapping tokensfunction Component() { const signer = useSigner(); // 1. get a quote for swapping tokens const quoteQuery = useBuyWithCryptoQuote(swapParams); const [buyTxHash, setBuyTxHash] = useState<string | undefined>(); const statusQuery = useBuyWithCryptoStatus( buyTxHash ? { clientId: "YOUR_CLIENT_ID", transactionHash: buyTxHash, } : undefined, ); async function handleBuyWithCrypto() { if (!quoteQuery.data || !signer) { return; } // 2. if approval is required if (quoteQuery.data.approval) { const approveTx = await signer.sendTransaction( quoteQuery.data.approval, ); await approveTx.wait(); } // 3. send the transaction to buy crypto const buyTx = await signer.sendTransaction( quoteQuery.data.transactionRequest, ); await buyTx.wait(); // set buyTx.transactionHash to poll the status of the swap transaction setBuyTxHash(buyTx.hash); } // 4. wait for the status of the transaction if (statusQuery.data) { console.log("swap status:", statusQuery.data); } return <button onClick={handleBuyWithCrypto}>Swap</button>; }
For more information, check out the pay documentation for purchases with crypto