CityOfZion / neo-lux

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

Support for custom networks #2

Closed Relfos closed 5 years ago

Relfos commented 6 years ago

Some users might need to test their dApps in a private test net, Neo-Lux must have a way to support this.

Relfos commented 6 years ago

Partially done, supports custom urls as API source.

dprat0821 commented 6 years ago

Hi Relfos. Thanks for your hard work. My project may need this feature very urgently so I tried to add a function in NeoRPC.cs

public static NeoRPC ForPrivateNet(string endpoint) { return new NeoRPC(endpoint); }

But when I used the private net IP (endpoint = "http://xxx.xx.xxx.xx") I got a timeout. Did I miss something? My code called in Unity is like:

var balances = NeoRPC.ForPrivateNet("http://xxx.xx.xxx.xx").GetBalancesOf(this.keys.address);

Thanks very much!

Relfos commented 6 years ago

Hi @dprat0821. NeoLux is written in a way to support multiple backends. There a couple different APIs that allow interaction with the blockchain, like the "official" Neo-cli RPC, the Neon-db API and the Neo-Scan API.

Currently NeoLux only supports Neon-db API, so if you supply a custom IP address, that should be a valid Neon-db server, not a Neo-cli node. However adding support for Neo-cli should be quite fast, I will give it a try today.

dprat0821 commented 6 years ago

Thanks Relfos. Thanks very much!

Relfos commented 6 years ago

Support for RPC is partially working now, so you can use it with private nets that are running Neo-cli. Only checking balances and testinvokes work, sending assets is not possible yet.

dprat0821 commented 6 years ago

Hi Relfos, Thanks very much. Would you please advice what I can add to the latest NEO-Lux if I need to implement sending assets (tokens, gas) in private net? Documents, sample code, etc. I can try that by myself.

Relfos commented 6 years ago

Hi, in latest version I split the main classes into NeoRPC and NeoDB, both have same interface, with NeoDB you can do everything but you will need to have the Neon DB API running in private net, heres a link with instructions: https://gist.github.com/birmas/689c37e43c7f55745233d3aeb794f833

If using NeoRPC you just need neo-cli in private net, but sending assets does not work yet due to to neo-cli missing an api method to fetch unspent inputs of an address.

Relfos commented 6 years ago

With latest version it is possible to use Neo.Lux with private nets if having NeoScan installed at the privatenet: https://github.com/slipo/neo-scan-docker

Dannynz commented 5 years ago

Hi Relfos, I am using Neo.Lux to invoke the smart contract on private chain (attached file). I debugged and saw response.state = FAULT and response.transaction = null, it means it could not add data to private chain, is it right? how can I test my smart contract with Neo.Lux on private chain? When you are available, please have a look then give me a hand. Thank you for your time. neoluxtest

Relfos commented 5 years ago

A nul transaction means that either there was a network failure or the RPC node rejected the transaction. Do you have GAS and NEO in this address? Or you might need to specify a RPC URL and port for private net instead of the default values

On Fri, Nov 9, 2018 at 12:29 AM Dannynz notifications@github.com wrote:

Hi Relfos, I am using Neo.Lux to invoke the smart contract on private chain (attached file). I debugged and saw response.status = FAULT and response.transaction = null, it means it could not add data to private chain, is it right? how can I test my smart contract with Neo.Lux on private chain? When you are available, please have a look then give me a hand. Thank you for your time. [image: neoluxtest] https://user-images.githubusercontent.com/12290489/48235501-05f91b80-e423-11e8-8b4a-d1474bf4493b.jpg

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/CityOfZion/neo-lux/issues/2#issuecomment-437206509, or mute the thread https://github.com/notifications/unsubscribe-auth/AGcXvia67TmEMqFsXSiD2gaueOCHIOILks5utMxPgaJpZM4Ru9oI .

Dannynz commented 5 years ago

Hi Relfos, Thank you for your feedback. Yes, there are a lots of NEO and GAS. I give you some the screenshots that what I did.

Dannynz commented 5 years ago

Hi Relfos, I am using NeoLux with NeoScan on Private net, I can get asset balance with NEO 100,000,000 and GAS 16,024 by using api.GetAssetBalancesOf(keys.address). Now I try to deploy smart contract by using api.DeployContract(...) method we expect to see an output for the "result" parameter as true but we keep returning false. Could you please look at these screenshots and give us some feedback. thank you for your help. contract debug method

Relfos commented 5 years ago

Hi, I don't think thats a valid value for the 'paras' variable, the chain might refuse that.

On Wed, Nov 21, 2018 at 2:17 AM Dannynz notifications@github.com wrote:

Hi Relfos, I am using NeoLux with NeoScan on Private net, I can get asset balance with NEO 100,000,000 and GAS 16,024 by using api.GetAssetBalancesOf(keys.address). Now I try to deploy smart contract by using api.DeployContract(...) method we expect to see an output for the "result" parameter as true but we keep returning false. Could you please look at these screenshots and give us some feedback. thank you for your help. [image: contract] https://user-images.githubusercontent.com/12290489/48814678-8e22dd80-eda0-11e8-8e2a-615847a1e457.PNG [image: debug] https://user-images.githubusercontent.com/12290489/48814679-8e22dd80-eda0-11e8-9426-c2494df1fb6b.png [image: method] https://user-images.githubusercontent.com/12290489/48814680-8e22dd80-eda0-11e8-802c-26c9affe52d6.PNG

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/CityOfZion/neo-lux/issues/2#issuecomment-440503848, or mute the thread https://github.com/notifications/unsubscribe-auth/AGcXvhWVvwfRJbo3ZAPnNvVtgZPVBQK6ks5uxLfMgaJpZM4Ru9oI .

Dannynz commented 5 years ago

Hi Relfos, Thank you so much for your feedback. I try to create another contract with string parameter type, but still get the same result = false. Is these some thing missing? When you are available, please give me a hand. Thank you so much for your help. image image

Relfos commented 5 years ago

It is possible that something changed in NEO recently. Try deploy the contract using NEO-gui first

On Wed, Nov 21, 2018 at 9:40 PM Dannynz notifications@github.com wrote:

Hi Relfos, Thank you so much for your feedback. I try to create another contract with string parameter type, but still get the same result = false. Is these some thing missing? When you are available, please give me a hand. Thank you so much for your help. [image: image] https://user-images.githubusercontent.com/12290489/48869576-959ac300-ee42-11e8-9177-82e667b310fb.png [image: image] https://user-images.githubusercontent.com/12290489/48869648-ddb9e580-ee42-11e8-8d72-bd393607bab3.png

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/CityOfZion/neo-lux/issues/2#issuecomment-440818666, or mute the thread https://github.com/notifications/unsubscribe-auth/AGcXvresCX1JsiFDR4_LaH0Z3EwfneBhks5uxchBgaJpZM4Ru9oI .

Dannynz commented 5 years ago

Hi @Relfos Relfos, Thank you for your quick reply. I will have a try. Have a nice day.

Dannynz commented 5 years ago

Hi @Relfos , Just give you an update. After restart docker, It works well now. Thank you so much for your help.

Dannynz commented 5 years ago

Hi @Relfos , After I deployed smart contract successfully. Then I try to add data to Private chain by calling the SetHello method, follow the debugger I got the result with state = FAULT and stack = empty. When you are available, please have a look then give some advice. Thank you for your help. image image invokescript

Relfos commented 5 years ago

Try providing a reversed scripthash string

On Thu, Nov 22, 2018 at 5:03 AM Dannynz notifications@github.com wrote:

Hi @Relfos https://github.com/Relfos , When I deployed smart contract successfully. Then I try to add data to Private chain by calling the SetHello method, follow the debugger I got the result with state = FAULT and stack = empty. When you are available, please have a look then give some advice. Thank you for your help. [image: image] https://user-images.githubusercontent.com/12290489/48882704-8f2b3c00-ee80-11e8-90f3-7af67fc7e35b.png [image: image] https://user-images.githubusercontent.com/12290489/48882728-b97cf980-ee80-11e8-8ff1-e55ca0c1130d.png [image: invokescript] https://user-images.githubusercontent.com/12290489/48882743-d44f6e00-ee80-11e8-8e51-5980a1b3f8e2.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CityOfZion/neo-lux/issues/2#issuecomment-440913586, or mute the thread https://github.com/notifications/unsubscribe-auth/AGcXvr23518cGhPSW_OQQ-vHldiemokJks5uxjAKgaJpZM4Ru9oI .

Dannynz commented 5 years ago

Hi @Relfos , Thank you for your feedback. I have tried providing a reversed scripthash string "0x884fd32dba7e664627f16312dd544847d41e7094", but still got the same result. When you are available, please have a look then give me some advice. Thank you so much. Have a nice day. test2

Dannynz commented 5 years ago

Hi @Relfos , Finally I tried to debug and found out the issue that if using void Main(string operation), there was an error message at Neo.VM (look at a screenshot) then I changed to bool Main(string operation), it works fine. Just give you an update. Thank you so much for your help and have a nice weekend. image