CityOfZion / neo-lux

.NET SDK to interact with the NEO blockchain and invoke smart contracts
MIT License
37 stars 24 forks source link

Can't call `public static object Main(string operation, params object[] args)` from `Demo.cs` #6

Closed mwherman2000 closed 6 years ago

mwherman2000 commented 6 years ago

I'm playing around with neo-lux tonight. Trying to call my NPCdApp:

Script Hash: 0x7074acf3f06dd3f456e11053ebf61c5b04b07ebc (testnet)

public static object Main(string operation, params object[] args) (link to source)

win-gui parameter type: 0710

I tried to change your Demo.cs in a simple way but I'm just getting a null result back (should get back the string "success"). Here's the 4 lines I added to your Demo.cs:

https://github.com/mwherman2000/neo-lux/blob/master/neo-lux-demo/Demo.cs#L51

var NPCdAppContractHash = "0x7074acf3f06dd3f456e11053ebf61c5b04b07ebc".Replace("0x", "");
var response2 = api.TestInvokeScript(NPCdAppContractHash, "test2", new object[] { new BigInteger(5) } );
var result2 = System.Text.Encoding.ASCII.GetString((byte[])response2.result);
Console.WriteLine("result2" + result2);

Is there a simple fix?

Here's the Main() for my SC: https://github.com/mwherman2000/neo-persistibleclasses/blob/master/NPCdApp/NPCdApp.cs#L96

Cheers, Michael

Relfos commented 6 years ago

Check the demo code, the lines before your new code: api = NeoRPC.ForMainNet();

I dont think you're using main net, so thats probably why you're not getting a result back

mwherman2000 commented 6 years ago

I was aware of the need for that call but I'm only going to take 50% of the "credit" for the problem. :smiley: I saw var api = NeoRPC.ForTestNet(); at the top of Main but didn't see api = NeoRPC.ForMainNet(); in the middle of the method. :smiley: ...thk u again :smiley: