|
38 | 38 |
|
39 | 39 | #region AI |
40 | 40 |
|
| 41 | +// Prepare some context |
41 | 42 | var myChain = 11155111; |
42 | 43 | var myWallet = await SmartWallet.Create(personalWallet: await PrivateKeyWallet.Generate(client), chainId: myChain, gasless: true); |
| 44 | +var myContractAddress = "0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8"; // DropERC1155 |
43 | 45 |
|
| 46 | +// Create a Nebula session |
44 | 47 | var nebula = await ThirdwebNebula.Create(client); |
45 | 48 |
|
46 | | -// var response = await nebula.Chat(message: "What is my wallet address?", wallet: myWallet); |
47 | | -// Console.WriteLine($"Single Response: {response.Message}"); |
48 | | - |
49 | | -// var responses = await nebula.Chat( |
50 | | -// messages: new List<string> { "What's the symbol of this contract?", "How much ETH does it have?" }, |
51 | | -// context: new NebulaContext(contractAddresses: new List<string> { "0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8" }, chainIds: new List<BigInteger> { myChain }) |
52 | | -// ); |
53 | | -// Console.WriteLine($"Multiple Responses: {responses.Message}"); |
54 | | - |
55 | | -// var receipt = await nebula.Execute( |
56 | | -// "Send a transaction with 0x data on sepolia to vitalik.eth using my wallet.", |
57 | | -// wallet: myWallet, |
58 | | -// context: new NebulaContext(chainIds: new List<BigInteger> { myChain }) |
59 | | -// ); |
| 49 | +// Chat, passing wallet context |
| 50 | +var response1 = await nebula.Chat(message: "What is my wallet address?", wallet: myWallet); |
| 51 | +Console.WriteLine($"Response 1: {response1.Message}"); |
| 52 | + |
| 53 | +// Chat, passing contract context |
| 54 | +var response2 = await nebula.Chat( |
| 55 | + message: "What's the total supply of token id 0 for this contract?", |
| 56 | + context: new NebulaContext(contractAddresses: new List<string> { myContractAddress }, chainIds: new List<BigInteger> { myChain }) |
| 57 | +); |
| 58 | +Console.WriteLine($"Response 2: {response2.Message}"); |
| 59 | + |
| 60 | +// Chat, passing multiple messages and context |
| 61 | +var response3 = await nebula.Chat( |
| 62 | + messages: new List<NebulaChatMessage> |
| 63 | + { |
| 64 | + new($"Tell me the name of this contract: {myContractAddress}", NebulaChatRole.User), |
| 65 | + new("The name of the contract is CatDrop", NebulaChatRole.Assistant), |
| 66 | + new("What's the symbol of this contract?", NebulaChatRole.User), |
| 67 | + }, |
| 68 | + context: new NebulaContext(contractAddresses: new List<string> { myContractAddress }, chainIds: new List<BigInteger> { myChain }) |
| 69 | +); |
| 70 | +Console.WriteLine($"Response 3: {response3.Message}"); |
| 71 | + |
| 72 | +// // Execute, this directly sends transactions |
| 73 | +// var receipt = await nebula.Execute("Send a valueless transaction to my wallet!", wallet: myWallet, context: new NebulaContext(chainIds: new List<BigInteger> { myChain })); |
60 | 74 | // Console.WriteLine($"Receipt: {JsonConvert.SerializeObject(receipt, Formatting.Indented)}"); |
61 | 75 |
|
62 | 76 | #endregion |
|
0 commit comments