|
13 | 13 | using Thirdweb;
|
14 | 14 | using Thirdweb.AccountAbstraction;
|
15 | 15 | using Thirdweb.AI;
|
| 16 | +using Thirdweb.Bridge; |
16 | 17 | using Thirdweb.Indexer;
|
17 | 18 | using Thirdweb.Pay;
|
18 | 19 |
|
|
41 | 42 |
|
42 | 43 | #endregion
|
43 | 44 |
|
| 45 | +#region Bridge |
| 46 | + |
| 47 | +// // Create a ThirdwebBridge instance |
| 48 | +// var bridge = await ThirdwebBridge.Create(client); |
| 49 | + |
| 50 | +// // Buy - Get a quote for buying a specific amount of tokens |
| 51 | +// var buyQuote = await bridge.Buy_Quote( |
| 52 | +// originChainId: 1, |
| 53 | +// originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum |
| 54 | +// destinationChainId: 324, |
| 55 | +// destinationTokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync |
| 56 | +// buyAmountWei: BigInteger.Parse("0.1".ToWei()) |
| 57 | +// ); |
| 58 | +// Console.WriteLine($"Buy quote: {JsonConvert.SerializeObject(buyQuote, Formatting.Indented)}"); |
| 59 | + |
| 60 | +// // Buy - Get an executable set of transactions (alongside a quote) for buying a specific amount of tokens |
| 61 | +// var preparedBuy = await bridge.Buy_Prepare( |
| 62 | +// originChainId: 1, |
| 63 | +// originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum |
| 64 | +// destinationChainId: 324, |
| 65 | +// destinationTokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync |
| 66 | +// buyAmountWei: BigInteger.Parse("0.1".ToWei()), |
| 67 | +// sender: await Utils.GetAddressFromENS(client, "vitalik.eth"), |
| 68 | +// receiver: await myWallet.GetAddress() |
| 69 | +// ); |
| 70 | +// Console.WriteLine($"Prepared Buy contains {preparedBuy.Transactions.Count} transaction(s)!"); |
| 71 | + |
| 72 | +// // Sell - Get a quote for selling a specific amount of tokens |
| 73 | +// var sellQuote = await bridge.Sell_Quote( |
| 74 | +// originChainId: 324, |
| 75 | +// originTokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync |
| 76 | +// destinationChainId: 1, |
| 77 | +// destinationTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum |
| 78 | +// sellAmountWei: BigInteger.Parse("0.1".ToWei()) |
| 79 | +// ); |
| 80 | +// Console.WriteLine($"Sell quote: {JsonConvert.SerializeObject(sellQuote, Formatting.Indented)}"); |
| 81 | + |
| 82 | +// // Sell - Get an executable set of transactions (alongside a quote) for selling a specific amount of tokens |
| 83 | +// var preparedSell = await bridge.Sell_Prepare( |
| 84 | +// originChainId: 324, |
| 85 | +// originTokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync |
| 86 | +// destinationChainId: 1, |
| 87 | +// destinationTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum |
| 88 | +// sellAmountWei: BigInteger.Parse("0.1".ToWei()), |
| 89 | +// sender: await Utils.GetAddressFromENS(client, "vitalik.eth"), |
| 90 | +// receiver: await myWallet.GetAddress() |
| 91 | +// ); |
| 92 | +// Console.WriteLine($"Prepared Sell contains {preparedSell.Transactions.Count} transaction(s)!"); |
| 93 | + |
| 94 | +// // Transfer - Get an executable transaction for transferring a specific amount of tokens |
| 95 | +// var preparedTransfer = await bridge.Transfer_Prepare( |
| 96 | +// chainId: 137, |
| 97 | +// tokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync |
| 98 | +// transferAmountWei: BigInteger.Parse("0.1".ToWei()), |
| 99 | +// sender: await Utils.GetAddressFromENS(client, "vitalik.eth"), |
| 100 | +// receiver: await myWallet.GetAddress() |
| 101 | +// ); |
| 102 | +// Console.WriteLine($"Prepared Transfer: {JsonConvert.SerializeObject(preparedTransfer, Formatting.Indented)}"); |
| 103 | + |
| 104 | +// // You may use our extensions to execute yourself... |
| 105 | +// var myTx = await preparedTransfer.Transactions[0].ToThirdwebTransaction(myWallet); |
| 106 | +// var myHash = await ThirdwebTransaction.Send(myTx); |
| 107 | + |
| 108 | +// // ...and poll for the status... |
| 109 | +// var status = await bridge.Status(transactionHash: myHash, chainId: 1); |
| 110 | +// var isComplete = status.StatusType == StatusType.COMPLETED; |
| 111 | +// Console.WriteLine($"Status: {JsonConvert.SerializeObject(status, Formatting.Indented)}"); |
| 112 | + |
| 113 | +// // Or use our Execute extensions directly to handle everything for you! |
| 114 | + |
| 115 | +// // Execute a prepared Buy |
| 116 | +// var buyResult = await bridge.Execute(myWallet, preparedBuy); |
| 117 | +// var buyHashes = buyResult.Select(receipt => receipt.TransactionHash).ToList(); |
| 118 | +// Console.WriteLine($"Buy hashes: {JsonConvert.SerializeObject(buyHashes, Formatting.Indented)}"); |
| 119 | + |
| 120 | +// // Execute a prepared Sell |
| 121 | +// var sellResult = await bridge.Execute(myWallet, preparedSell); |
| 122 | +// var sellHashes = sellResult.Select(receipt => receipt.TransactionHash).ToList(); |
| 123 | +// Console.WriteLine($"Sell hashes: {JsonConvert.SerializeObject(sellHashes, Formatting.Indented)}"); |
| 124 | + |
| 125 | +// // Execute a prepared Transfer |
| 126 | +// var transferResult = await bridge.Execute(myWallet, preparedTransfer); |
| 127 | +// var transferHashes = transferResult.Select(receipt => receipt.TransactionHash).ToList(); |
| 128 | +// Console.WriteLine($"Transfer hashes: {JsonConvert.SerializeObject(transferHashes, Formatting.Indented)}"); |
| 129 | + |
| 130 | +#endregion |
| 131 | + |
44 | 132 | #region Indexer
|
45 | 133 |
|
46 | 134 | // // Create a ThirdwebInsight instance
|
|
0 commit comments