neo-one
neo-one copied to clipboard
Investigate neo-cli contract invocation
While we are able to generate .avm
and compatible .abi.json
files with #2071 there is still work to be done if someone wanted to invoke these contracts with another framework / node.
While you can successfully publish a contract to either neo-express or neo-cli the only method that is successfully invoked is deploy
. Interestingly deploy
seems to work exactly as you'd expect, on first invoke it costs ~1+ gas and returns true
and on successive invokes it costs <0.1gas and returns nothing.
Other methods like hello
in my example contract at https://github.com/danwbyrne/neo-ts-compile only return a vm state of FAULT
without much more information.
Thoughts
This seems like it has to be a difference in how we construct / call invocation transactions using neo-one. We KNOW after #2096 that these contract methods DO work on the live chain when invoked from a neo-one client but they fail to invoke successfully when called from the neo-cli.
Maybe our contracts have to have the publish / deploy invocations combined? I can't imagine why this would be necessary, all that publishAndDeploy
does in @neo-one/client-full-core
is combine the two invocations in the script. https://github.com/neo-one-suite/neo-one/blob/769a619526415dcc45a0132b5197a50ebdb10958/packages/neo-one-client-full-core/src/user/LocalUserAccountProvider.ts#L140
Could it have to do with how we don't use invokeScript
or invokeFunction
in the same way as neo-cli
?
We can only call one method in neo-cli, unless modify it by yourself.
@ProDog where would I be looking to make those modifications?
also just to clarify where I am failing:
deploy /path/to/contract.avm HelloWorld
invoke <hash> deploy
invoke <hash> hello test // fails here
When I added some Console.WriteLines(...)
here https://github.com/neo-project/neo-node/blob/f81e60bac50c877f347bf04119b24d5afff158b7/neo-cli/Shell/MainService.cs#L218 I was able to see the invocation script looked like I was expecting when I tried to invoke the hello
method but it still fails.
@danwbyrne I guess the main thing you want to know is why failed? We cannot see exactly where the contract fails in neo-cli, after checking the contract and version and so on are correct, we can use notify in the contract to test the location of failure.