CityOfZion / neo-python

Python Node and SDK for the NEO 2.x blockchain. For NEO 3.x go to our successor project neo-mamba
https://neo-python.readthedocs.io/en/latest/
MIT License
313 stars 189 forks source link

About NEP-5 Smart Contracts #1032

Open WAELKASSEM opened 4 years ago

WAELKASSEM commented 4 years ago

I am using the template provided below : https://github.com/CityOfZion/neo-boa/blob/master/boa_test/example/demo/NEP5.py And neo-local , to create and deploy locally an NEP-5 token. The process of build and deploy using the related commands runs successfully .

However the INVOKE command doesn't ! The command 'show contracts all' doesn't list this smart contract , but it shows my other non NEP-5 smart contracts. I cannot find my contract using its hash. The command 'show assets all' doesn't show my token either.

I can only test its functionality using build_run command, and it works.

Any help would be appreciated.

ixje commented 4 years ago

please describe the exact commands you used to build and deploy and to which network (private net, testnet?). It sounds like you're either doing a test invoke without actually permanently deploying the contract to a chain, or your local chain is out of sync.

WAELKASSEM commented 4 years ago

1- sc build 2 - sc deploy True False False etc.... I get no errors. Everything happens the same as deploying another smart contract but not NEP-5 .

using private_net.

ixje commented 4 years ago

which exact neo-python version are you using? You can type np-prompt --version assuming you followed the default installation instructions. Otherwise try cat neo/__init__.py

WAELKASSEM commented 4 years ago

I'm using neo-local , it always pulls the latest neo-python. And I've imported neo-boa v 0.6.0 to my python project .

someone-somenet-org commented 3 years ago

Same issue here, today. It seems everything is fine, but the contract just wont get deployed.

I am using the docker image: docker run --rm -d --name neo-privatenet -v /home/.../mynep5/:/neo-python/sc -p 20333-20336:20333-20336/tcp -p 30333-30336:30333-30336/tcp cityofzion/neo-privatenet

I can run things with sc build_run .... like:

(noop and noopowner just return True, noopowner does a checkwitness check before)

But I cannot make neopy deploy that contract to privtestnet. I can transfer neo and gas from the "generic coz-privkey" to my myPrivTestnetAddr. One weird thing: I have 32k gas in the privtestnet, but once I deploy twice, any third attempt will fail with "insufficient funds", but checking wallet there was nothing deducted. Wiping and restarting the container "fixes" it by granting me another 2 deploys.

Unsure how to debug.

Also out of frustration I tried to get my nep5token deployed on public testnet with neo-cli. That worked without any confirmation and I can call unprivileged functions on testnet. Another issue is: I cant manage to use neo-cli to call functions that use checkWitness. There is one single example that feeds some scripthashes and some address to a transfer function, but reproducing that with what I think it means (yay docs! -.-) doesnt work.

This all needs not more examples - there are examples everywhere - but a good written one that explains the non-obvious constraints and assumptions and how to turn on debugging everywhere.

ixje commented 3 years ago
someone-somenet-org commented 3 years ago
  • Have you tried attaching extra gas on the deploy transaction? Shouldn't be required but worth a try.

no. how would I do that with neopy or neo-cli?

I later managed to do that with neoline on pubtestnet, but I failed to do that with neopy and neo-cli. how would I do that with those?

  • As for the double/triple deploy. I've not heard of that before, but you could try running the wallet rebuild command

created container, opened wallet, waited 15 min, ran wallet rebuild, waited 15 min.

still only 2 deploys, that wont actually deploy, the 3. one will fail with insufficient funds.

ixje commented 3 years ago
  • Have you tried attaching extra gas on the deploy transaction? Shouldn't be required but worth a try.

no. how would I do that with neopy or neo-cli?

For neo-cli ask on the neo-cli repo. I don't know. For neo-python, use --attach-gas when invoking (see sc invoke help).

I later managed to do that with neoline on pubtestnet, but I failed to do that with neopy and neo-cli. how would I do that with those?

use --tx-attr when invoking. Again see sc invoke help it has an example in the help description. the "usage" value should be 0x20 and the "data" has to be 20 bytes long because it expects to convert it to a UInt160 https://github.com/CityOfZion/neo-python/blob/f343df6c50c5bd39eb0d812c8dc011f717a7df93/neo/Core/TX/Transaction.py#L716-L720 The conversion part is called by this https://github.com/CityOfZion/neo-python/blob/f343df6c50c5bd39eb0d812c8dc011f717a7df93/neo/SmartContract/StateReader.py#L200

  • As for the double/triple deploy. I've not heard of that before, but you could try running the wallet rebuild command

created container, opened wallet, waited 15 min, ran wallet rebuild, waited 15 min.

still only 2 deploys, that wont actually deploy, the 3. one will fail with insufficient funds.

Sorry, no idea what is going on there then.