|
101 | 101 |
|
102 | 102 | #endregion |
103 | 103 |
|
| 104 | +#region Thirdweb API Wrapper |
| 105 | + |
| 106 | +var metadata = await client.Api.GetContractMetadataAsync(chainId: 1, address: "0xBd3531dA5CF5857e7CfAA92426877b022e612cf8"); |
| 107 | + |
| 108 | +Console.WriteLine($"ABI: {JsonConvert.SerializeObject(metadata.Result.Output.Abi, Formatting.Indented)}"); |
| 109 | +Console.WriteLine($"Compiler version: {metadata.Result.Compiler.Version}"); |
| 110 | + |
| 111 | +#endregion |
| 112 | + |
104 | 113 | #region AA 0.6 |
105 | 114 |
|
106 | | -var smartWallet06 = await SmartWallet.Create(personalWallet: guestWallet, chainId: 421614, gasless: true); |
107 | | -var receipt06 = await smartWallet06.Transfer(chainId: 421614, toAddress: await smartWallet06.GetAddress(), weiAmount: 0); |
108 | | -Console.WriteLine($"Receipt: {receipt06}"); |
| 115 | +// var smartWallet06 = await SmartWallet.Create(personalWallet: guestWallet, chainId: 421614, gasless: true); |
| 116 | +// var receipt06 = await smartWallet06.Transfer(chainId: 421614, toAddress: await smartWallet06.GetAddress(), weiAmount: 0); |
| 117 | +// Console.WriteLine($"Receipt: {receipt06}"); |
109 | 118 |
|
110 | 119 | #endregion |
111 | 120 |
|
|
149 | 158 |
|
150 | 159 | #endregion |
151 | 160 |
|
152 | | -#region Bridge |
153 | | - |
154 | | -// // Create a ThirdwebBridge instance |
155 | | -// var bridge = await ThirdwebBridge.Create(client); |
156 | | - |
157 | | -// // Buy - Get a quote for buying a specific amount of tokens |
158 | | -// var buyQuote = await bridge.Buy_Quote( |
159 | | -// originChainId: 1, |
160 | | -// originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum |
161 | | -// destinationChainId: 324, |
162 | | -// destinationTokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync |
163 | | -// buyAmountWei: BigInteger.Parse("0.01".ToWei()) |
164 | | -// ); |
165 | | -// Console.WriteLine($"Buy quote: {JsonConvert.SerializeObject(buyQuote, Formatting.Indented)}"); |
166 | | - |
167 | | -// // Buy - Get an executable set of transactions (alongside a quote) for buying a specific amount of tokens |
168 | | -// var preparedBuy = await bridge.Buy_Prepare( |
169 | | -// originChainId: 1, |
170 | | -// originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum |
171 | | -// destinationChainId: 324, |
172 | | -// destinationTokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync |
173 | | -// buyAmountWei: BigInteger.Parse("0.01".ToWei()), |
174 | | -// sender: await Utils.GetAddressFromENS(client, "vitalik.eth"), |
175 | | -// receiver: await myWallet.GetAddress() |
176 | | -// ); |
177 | | -// Console.WriteLine($"Prepared Buy contains {preparedBuy.Steps.Count} steps(s) with a total of {preparedBuy.Steps.Sum(step => step.Transactions.Count)} transactions!"); |
178 | | - |
179 | | -// // Sell - Get a quote for selling a specific amount of tokens |
180 | | -// var sellQuote = await bridge.Sell_Quote( |
181 | | -// originChainId: 324, |
182 | | -// originTokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync |
183 | | -// destinationChainId: 1, |
184 | | -// destinationTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum |
185 | | -// sellAmountWei: BigInteger.Parse("0.01".ToWei()) |
186 | | -// ); |
187 | | -// Console.WriteLine($"Sell quote: {JsonConvert.SerializeObject(sellQuote, Formatting.Indented)}"); |
188 | | - |
189 | | -// // Sell - Get an executable set of transactions (alongside a quote) for selling a specific amount of tokens |
190 | | -// var preparedSell = await bridge.Sell_Prepare( |
191 | | -// originChainId: 324, |
192 | | -// originTokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync |
193 | | -// destinationChainId: 1, |
194 | | -// destinationTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum |
195 | | -// sellAmountWei: BigInteger.Parse("0.01".ToWei()), |
196 | | -// sender: await Utils.GetAddressFromENS(client, "vitalik.eth"), |
197 | | -// receiver: await myWallet.GetAddress() |
198 | | -// ); |
199 | | -// Console.WriteLine($"Prepared Sell contains {preparedBuy.Steps.Count} steps(s) with a total of {preparedBuy.Steps.Sum(step => step.Transactions.Count)} transactions!"); |
200 | | - |
201 | | -// // Transfer - Get an executable transaction for transferring a specific amount of tokens |
202 | | -// var preparedTransfer = await bridge.Transfer_Prepare( |
203 | | -// chainId: 137, |
204 | | -// tokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // POL on Polygon |
205 | | -// transferAmountWei: BigInteger.Parse("0.01".ToWei()), |
206 | | -// sender: await Utils.GetAddressFromENS(client, "vitalik.eth"), |
207 | | -// receiver: await myWallet.GetAddress() |
208 | | -// ); |
209 | | -// Console.WriteLine($"Prepared Transfer: {JsonConvert.SerializeObject(preparedTransfer, Formatting.Indented)}"); |
210 | | - |
211 | | -// // You may use our extensions to execute yourself... |
212 | | -// var myTx = await preparedTransfer.Transactions[0].ToThirdwebTransaction(myWallet); |
213 | | -// var myHash = await ThirdwebTransaction.Send(myTx); |
214 | | - |
215 | | -// // ...and poll for the status... |
216 | | -// var status = await bridge.Status(transactionHash: myHash, chainId: 1); |
217 | | -// var isComplete = status.StatusType == StatusType.COMPLETED; |
218 | | -// Console.WriteLine($"Status: {JsonConvert.SerializeObject(status, Formatting.Indented)}"); |
219 | | - |
220 | | -// // Or use our Execute extensions directly to handle everything for you! |
221 | | - |
222 | | -// // Execute a prepared Buy |
223 | | -// var buyResult = await bridge.Execute(myWallet, preparedBuy); |
224 | | -// var buyHashes = buyResult.Select(receipt => receipt.TransactionHash).ToList(); |
225 | | -// Console.WriteLine($"Buy hashes: {JsonConvert.SerializeObject(buyHashes, Formatting.Indented)}"); |
226 | | - |
227 | | -// // Execute a prepared Sell |
228 | | -// var sellResult = await bridge.Execute(myWallet, preparedSell); |
229 | | -// var sellHashes = sellResult.Select(receipt => receipt.TransactionHash).ToList(); |
230 | | -// Console.WriteLine($"Sell hashes: {JsonConvert.SerializeObject(sellHashes, Formatting.Indented)}"); |
231 | | - |
232 | | -// // Execute a prepared Transfer |
233 | | -// var transferResult = await bridge.Execute(myWallet, preparedTransfer); |
234 | | -// var transferHashes = transferResult.Select(receipt => receipt.TransactionHash).ToList(); |
235 | | -// Console.WriteLine($"Transfer hashes: {JsonConvert.SerializeObject(transferHashes, Formatting.Indented)}"); |
236 | | - |
237 | | -// // Onramp - Get a quote for buying crypto with Fiat |
238 | | -// var preparedOnramp = await bridge.Onramp_Prepare( |
239 | | -// onramp: OnrampProvider.Coinbase, |
240 | | -// chainId: 8453, |
241 | | -// tokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base |
242 | | -// amount: "10000000", |
243 | | -// receiver: await myWallet.GetAddress() |
244 | | -// ); |
245 | | -// Console.WriteLine($"Onramp link: {preparedOnramp.Link}"); |
246 | | -// Console.WriteLine($"Full onramp quote and steps data: {JsonConvert.SerializeObject(preparedOnramp, Formatting.Indented)}"); |
247 | | - |
248 | | -// while (true) |
249 | | -// { |
250 | | -// var onrampStatus = await bridge.Onramp_Status(id: preparedOnramp.Id); |
251 | | -// Console.WriteLine($"Full Onramp Status: {JsonConvert.SerializeObject(onrampStatus, Formatting.Indented)}"); |
252 | | -// if (onrampStatus.StatusType is StatusType.COMPLETED or StatusType.FAILED) |
253 | | -// { |
254 | | -// break; |
255 | | -// } |
256 | | -// await ThirdwebTask.Delay(5000); |
257 | | -// } |
258 | | - |
259 | | -// if (preparedOnramp.IsSwapRequiredPostOnramp()) |
260 | | -// { |
261 | | -// // Execute additional steps that are required post-onramp to get to your token, manually or via the Execute extension |
262 | | -// var receipts = await bridge.Execute(myWallet, preparedOnramp); |
263 | | -// Console.WriteLine($"Onramp receipts: {JsonConvert.SerializeObject(receipts, Formatting.Indented)}"); |
264 | | -// } |
265 | | -// else |
266 | | -// { |
267 | | -// Console.WriteLine("No additional steps required post-onramp, you can use the tokens directly!"); |
268 | | -// } |
269 | | - |
270 | | -#endregion |
271 | | - |
272 | 161 | #region Get Social Profiles |
273 | 162 |
|
274 | 163 | // var socialProfiles = await Utils.GetSocialProfiles(client, "joenrv.eth"); |
|
592 | 481 |
|
593 | 482 | #endregion |
594 | 483 |
|
595 | | -#region Self Transfer Transaction |
596 | | - |
597 | | -// var tx = await ThirdwebTransaction.Create( |
598 | | -// wallet: privateKeyWallet, |
599 | | -// txInput: new ThirdwebTransactionInput() |
600 | | -// { |
601 | | -// To = await privateKeyWallet.GetAddress(), |
602 | | -// Value = new HexBigInteger(BigInteger.Zero), |
603 | | -// }, |
604 | | -// chainId: 842 |
605 | | -// ); |
606 | | -// var txHash = await ThirdwebTransaction.Send(tx); |
607 | | -// Console.WriteLine($"Transaction hash: {txHash}"); |
608 | | - |
609 | | -#endregion |
610 | | - |
611 | | -#region Smart Wallet - Gasless Transaction |
612 | | - |
613 | | -// var smartWallet = await SmartWallet.Create(privateKeyWallet, 78600); |
614 | | - |
615 | | -// // Self transfer 0 |
616 | | -// var tx2 = await ThirdwebTransaction.Create( |
617 | | -// smartWallet, |
618 | | -// new ThirdwebTransactionInput() |
619 | | -// { |
620 | | -// To = await smartWallet.GetAddress(), |
621 | | -// Value = new HexBigInteger(BigInteger.Zero) |
622 | | -// }, |
623 | | -// 78600 |
624 | | -// ); |
625 | | -// var txHash2 = await ThirdwebTransaction.Send(tx2); |
626 | | -// Console.WriteLine($"Transaction hash: {txHash2}"); |
627 | | - |
628 | | -#endregion |
629 | | - |
630 | 484 | #region Storage Actions |
631 | 485 |
|
632 | 486 | // // Will download from IPFS or normal urls |
|
0 commit comments