|
38 | 38 |
|
39 | 39 | #region AI
|
40 | 40 |
|
41 |
| -// Prepare some context |
42 |
| -var myChain = 11155111; |
43 |
| -var myWallet = await SmartWallet.Create(personalWallet: await PrivateKeyWallet.Generate(client), chainId: myChain, gasless: true); |
44 |
| -var myContractAddress = "0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8"; // DropERC1155 |
45 |
| -var usdcAddress = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"; |
46 |
| - |
47 |
| -// Create a Nebula session |
48 |
| -var nebula = await ThirdwebNebula.Create(client); |
49 |
| - |
50 |
| -// Chat, passing wallet context |
51 |
| -var response1 = await nebula.Chat(message: "What is my wallet address?", wallet: myWallet); |
52 |
| -Console.WriteLine($"Response 1: {response1.Message}"); |
53 |
| - |
54 |
| -// Chat, passing contract context |
55 |
| -var response2 = await nebula.Chat( |
56 |
| - message: "What's the total supply of token id 0 for this contract?", |
57 |
| - context: new NebulaContext(contractAddresses: new List<string> { myContractAddress }, chainIds: new List<BigInteger> { myChain }) |
58 |
| -); |
59 |
| -Console.WriteLine($"Response 2: {response2.Message}"); |
60 |
| - |
61 |
| -// Chat, passing multiple messages and context |
62 |
| -var response3 = await nebula.Chat( |
63 |
| - messages: new List<NebulaChatMessage> |
64 |
| - { |
65 |
| - new($"Tell me the name of this contract: {myContractAddress}", NebulaChatRole.User), |
66 |
| - new("The name of the contract is CatDrop", NebulaChatRole.Assistant), |
67 |
| - new("What's the symbol of this contract?", NebulaChatRole.User), |
68 |
| - }, |
69 |
| - context: new NebulaContext(contractAddresses: new List<string> { myContractAddress }, chainIds: new List<BigInteger> { myChain }) |
70 |
| -); |
71 |
| -Console.WriteLine($"Response 3: {response3.Message}"); |
72 |
| - |
73 |
| -// Execute, this directly sends transactions |
74 |
| -var executionResult = await nebula.Execute("Approve 1 USDC to vitalik.eth", wallet: myWallet, context: new NebulaContext(contractAddresses: new List<string>() { usdcAddress })); |
75 |
| -if (executionResult.TransactionReceipts != null && executionResult.TransactionReceipts.Count > 0) |
76 |
| -{ |
77 |
| - Console.WriteLine($"Receipt: {executionResult.TransactionReceipts[0]}"); |
78 |
| -} |
79 |
| -else |
80 |
| -{ |
81 |
| - Console.WriteLine($"Message: {executionResult.Message}"); |
82 |
| -} |
83 |
| - |
84 |
| -// Batch execute |
85 |
| -var batchExecutionResult = await nebula.Execute( |
86 |
| - new List<NebulaChatMessage> |
87 |
| - { |
88 |
| - new("What's the address of vitalik.eth", NebulaChatRole.User), |
89 |
| - new("The address of vitalik.eth is 0xd8dA6BF26964aF8E437eEa5e3616511D7G3a3298", NebulaChatRole.Assistant), |
90 |
| - new("Approve 1 USDC to them", NebulaChatRole.User), |
91 |
| - }, |
92 |
| - wallet: myWallet, |
93 |
| - context: new NebulaContext(contractAddresses: new List<string>() { usdcAddress }) |
94 |
| -); |
95 |
| -if (batchExecutionResult.TransactionReceipts != null && batchExecutionResult.TransactionReceipts.Count > 0) |
96 |
| -{ |
97 |
| - Console.WriteLine($"Receipts: {JsonConvert.SerializeObject(batchExecutionResult.TransactionReceipts, Formatting.Indented)}"); |
98 |
| -} |
99 |
| -else |
100 |
| -{ |
101 |
| - Console.WriteLine($"Message: {batchExecutionResult.Message}"); |
102 |
| -} |
| 41 | +// // Prepare some context |
| 42 | +// var myChain = 11155111; |
| 43 | +// var myWallet = await SmartWallet.Create(personalWallet: await PrivateKeyWallet.Generate(client), chainId: myChain, gasless: true); |
| 44 | +// var myContractAddress = "0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8"; // DropERC1155 |
| 45 | +// var usdcAddress = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"; |
| 46 | + |
| 47 | +// // Create a Nebula session |
| 48 | +// var nebula = await ThirdwebNebula.Create(client); |
| 49 | + |
| 50 | +// // Chat, passing wallet context |
| 51 | +// var response1 = await nebula.Chat(message: "What is my wallet address?", wallet: myWallet); |
| 52 | +// Console.WriteLine($"Response 1: {response1.Message}"); |
| 53 | + |
| 54 | +// // Chat, passing contract context |
| 55 | +// var response2 = await nebula.Chat( |
| 56 | +// message: "What's the total supply of token id 0 for this contract?", |
| 57 | +// context: new NebulaContext(contractAddresses: new List<string> { myContractAddress }, chainIds: new List<BigInteger> { myChain }) |
| 58 | +// ); |
| 59 | +// Console.WriteLine($"Response 2: {response2.Message}"); |
| 60 | + |
| 61 | +// // Chat, passing multiple messages and context |
| 62 | +// var response3 = await nebula.Chat( |
| 63 | +// messages: new List<NebulaChatMessage> |
| 64 | +// { |
| 65 | +// new($"Tell me the name of this contract: {myContractAddress}", NebulaChatRole.User), |
| 66 | +// new("The name of the contract is CatDrop", NebulaChatRole.Assistant), |
| 67 | +// new("What's the symbol of this contract?", NebulaChatRole.User), |
| 68 | +// }, |
| 69 | +// context: new NebulaContext(contractAddresses: new List<string> { myContractAddress }, chainIds: new List<BigInteger> { myChain }) |
| 70 | +// ); |
| 71 | +// Console.WriteLine($"Response 3: {response3.Message}"); |
| 72 | + |
| 73 | +// // Execute, this directly sends transactions |
| 74 | +// var executionResult = await nebula.Execute("Approve 1 USDC to vitalik.eth", wallet: myWallet, context: new NebulaContext(contractAddresses: new List<string>() { usdcAddress })); |
| 75 | +// if (executionResult.TransactionReceipts != null && executionResult.TransactionReceipts.Count > 0) |
| 76 | +// { |
| 77 | +// Console.WriteLine($"Receipt: {executionResult.TransactionReceipts[0]}"); |
| 78 | +// } |
| 79 | +// else |
| 80 | +// { |
| 81 | +// Console.WriteLine($"Message: {executionResult.Message}"); |
| 82 | +// } |
| 83 | + |
| 84 | +// // Batch execute |
| 85 | +// var batchExecutionResult = await nebula.Execute( |
| 86 | +// new List<NebulaChatMessage> |
| 87 | +// { |
| 88 | +// new("What's the address of vitalik.eth", NebulaChatRole.User), |
| 89 | +// new("The address of vitalik.eth is 0xd8dA6BF26964aF8E437eEa5e3616511D7G3a3298", NebulaChatRole.Assistant), |
| 90 | +// new("Approve 1 USDC to them", NebulaChatRole.User), |
| 91 | +// }, |
| 92 | +// wallet: myWallet, |
| 93 | +// context: new NebulaContext(contractAddresses: new List<string>() { usdcAddress }) |
| 94 | +// ); |
| 95 | +// if (batchExecutionResult.TransactionReceipts != null && batchExecutionResult.TransactionReceipts.Count > 0) |
| 96 | +// { |
| 97 | +// Console.WriteLine($"Receipts: {JsonConvert.SerializeObject(batchExecutionResult.TransactionReceipts, Formatting.Indented)}"); |
| 98 | +// } |
| 99 | +// else |
| 100 | +// { |
| 101 | +// Console.WriteLine($"Message: {batchExecutionResult.Message}"); |
| 102 | +// } |
103 | 103 |
|
104 | 104 | #endregion
|
105 | 105 |
|
|
0 commit comments