@@ -20,14 +20,14 @@ Each operation provides two functions:
2020#### Buy Example
2121
2222``` typescript
23- import { Bridge , toWei } from " thirdweb" ;
23+ import { Bridge , toWei , NATIVE_TOKEN_ADDRESS } from " thirdweb" ;
2424
2525// First, get a quote to see approximately how much you'll pay
2626const buyQuote = await Bridge .Buy .quote ({
2727 originChainId: 1 , // Ethereum
28- originTokenAddress: " 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE " , // ETH
28+ originTokenAddress: NATIVE_TOKEN_ADDRESS ,
2929 destinationChainId: 10 , // Optimism
30- destinationTokenAddress: " 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE " , // ETH
30+ destinationTokenAddress: NATIVE_TOKEN_ADDRESS ,
3131 buyAmountWei: toWei (" 0.01" ), // I want to receive 0.01 ETH on Optimism
3232 client: thirdwebClient ,
3333});
@@ -37,9 +37,9 @@ console.log(`To get ${buyQuote.destinationAmount} wei on destination chain, you
3737// When ready to execute, prepare the transaction
3838const preparedBuy = await Bridge .Buy .prepare ({
3939 originChainId: 1 ,
40- originTokenAddress: " 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE " ,
40+ originTokenAddress: NATIVE_TOKEN_ADDRESS ,
4141 destinationChainId: 10 ,
42- destinationTokenAddress: " 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE " ,
42+ destinationTokenAddress: NATIVE_TOKEN_ADDRESS ,
4343 buyAmountWei: toWei (" 0.01" ),
4444 sender: " 0x..." , // Your wallet address
4545 receiver: " 0x..." , // Recipient address (can be the same as sender)
@@ -58,9 +58,9 @@ import { Bridge, toWei } from "thirdweb";
5858// First, get a quote to see approximately how much you'll receive
5959const sellQuote = await Bridge .Sell .quote ({
6060 originChainId: 1 , // Ethereum
61- originTokenAddress: " 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE " , // ETH
61+ originTokenAddress: NATIVE_TOKEN_ADDRESS ,
6262 destinationChainId: 10 , // Optimism
63- destinationTokenAddress: " 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE " , // ETH
63+ destinationTokenAddress: NATIVE_TOKEN_ADDRESS ,
6464 sellAmountWei: toWei (" 0.01" ), // I want to sell 0.01 ETH from Ethereum
6565 client: thirdwebClient ,
6666});
@@ -70,9 +70,9 @@ console.log(`If you send ${sellQuote.originAmount} wei, you'll receive approxima
7070// When ready to execute, prepare the transaction
7171const preparedSell = await Bridge .Sell .prepare ({
7272 originChainId: 1 ,
73- originTokenAddress: " 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE " ,
73+ originTokenAddress: NATIVE_TOKEN_ADDRESS ,
7474 destinationChainId: 10 ,
75- destinationTokenAddress: " 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE " ,
75+ destinationTokenAddress: NATIVE_TOKEN_ADDRESS ,
7676 sellAmountWei: toWei (" 0.01" ),
7777 sender: " 0x..." , // Your wallet address
7878 receiver: " 0x..." , // Recipient address (can be the same as sender)
@@ -91,7 +91,7 @@ for (const tx of preparedSell.transactions) {
9191You can discover available bridge routes using the ` routes ` function:
9292
9393``` typescript
94- import { Bridge } from " thirdweb" ;
94+ import { Bridge , NATIVE_TOKEN_ADDRESS } from " thirdweb" ;
9595
9696// Get all available routes
9797const allRoutes = await Bridge .routes ({
@@ -101,7 +101,7 @@ const allRoutes = await Bridge.routes({
101101// Filter routes for a specific token or chain
102102const filteredRoutes = await Bridge .routes ({
103103 originChainId: 1 , // From Ethereum
104- originTokenAddress: " 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE " , // ETH
104+ originTokenAddress: NATIVE_TOKEN_ADDRESS ,
105105 destinationChainId: 10 , // To Optimism
106106 client: thirdwebClient ,
107107});
0 commit comments