Closed kentarohorie closed 5 years ago
After reviewing similar issues in Discord, it seems import token {contract hash}
sometimes requires the user to exit the cli then restart np-prompt and try again. Have you tried this?
Are you using a self-made NEP5 token contract or is it based on a template contract like NEX, Moonlight, MCT?
I'm assuming you're using a private network. Can you please share the console log starting from the build
command, to import contract
, to import token
. The information of using those commands + their return values should give a good idea of a possible root cause. Thanks
@jseagrave21
Yes, I retry at least 5 times or more. I repeated build, import contract, deploy, import token.
I suspect my token's have problem because I can import token nex ico template. So, I want to know reason why I can't import my token.
I confirmed deference between nex ico template and mine, and "import token"'s mechanism, but I can't resolve
It is impossible to tell without any reproducible code. Can you share your contract code so we can try to debug/help you?
@ixje
This is commands and log. https://gist.github.com/kentarohorie/140efd1b9a6d6614f04dea2501702e1c
I want to share all code but I can't because of client...sorry so, what part of the contract code do we need for debug?
thanks for your help
so, what part of the contract code do we need for debug?
I don't know because it depends on where the bug is.
Try the following:
name
, symbol
and decimals
. testinvoke <contract hash> <command> []
. So according to your log you would use e.g.
testinvoke 0x1482f699725e02ee7bd9026695c0c6c779d9b02f name []
testinvoke 0x1482f699725e02ee7bd9026695c0c6c779d9b02f symbol []
testinvoke 0x1482f699725e02ee7bd9026695c0c6c779d9b02f decimals []
Let us know the output. I'm guessing one of these commands will fail and that's where the import failure comes from.
this is the output.
neo> testinvoke 0x1482f699725e02ee7bd9026695c0c6c779d9b02f name []
[I 181207 06:10:45 EventHub:58] [test_mode][SmartContract.Storage.Get] [1482f699725e02ee7bd9026695c0c6c779d9b02f] {'type': 'String', 'value': "b'contract_admin' -> bytearray(b'')"}
[I 181207 06:10:45 EventHub:58] [test_mode][SmartContract.Execution.Success] [1482f699725e02ee7bd9026695c0c6c779d9b02f] {'type': 'Array', 'value': [{'type': 'ByteArray', 'value': b'my token name'}]}
Used 0.249 Gas
-------------------------------------------------------------------------------------------------------------------------------------
Test invoke successful
Total operations: 235
Results [{'type': 'ByteArray', 'value': 'strings of number and character'}]
Invoke TX GAS cost: 0.0
Invoke TX fee: 0.0001
-------------------------------------------------------------------------------------------------------------------------------------
Enter your password to continue and invoke on the network
[password]>
Incorrect password
neo> testinvoke 0x1482f699725e02ee7bd9026695c0c6c779d9b02f symbol []
[I 181207 06:10:54 EventHub:58] [test_mode][SmartContract.Storage.Get] [1482f699725e02ee7bd9026695c0c6c779d9b02f] {'type': 'String', 'value': "b'contract_admin' -> bytearray(b'')"}
[I 181207 06:10:54 EventHub:58] [test_mode][SmartContract.Execution.Success] [1482f699725e02ee7bd9026695c0c6c779d9b02f] {'type': 'Array', 'value': [{'type': 'ByteArray', 'value': b'my token symbol(3 length string)'}]}
Used 0.283 Gas
-------------------------------------------------------------------------------------------------------------------------------------
Test invoke successful
Total operations: 288
Results [{'type': 'ByteArray', 'value': 'strings of number'}]
Invoke TX GAS cost: 0.0
Invoke TX fee: 0.0001
-------------------------------------------------------------------------------------------------------------------------------------
Enter your password to continue and invoke on the network
[password]>
Incorrect password
neo> testinvoke 0x1482f699725e02ee7bd9026695c0c6c779d9b02f decimals []
[I 181207 06:11:00 EventHub:58] [test_mode][SmartContract.Storage.Get] [1482f699725e02ee7bd9026695c0c6c779d9b02f] {'type': 'String', 'value': "b'contract_admin' -> bytearray(b'')"}
[I 181207 06:11:00 EventHub:58] [test_mode][SmartContract.Execution.Success] [1482f699725e02ee7bd9026695c0c6c779d9b02f] {'type': 'Array', 'value': [{'type': 'Integer', 'value': '8'}]}
Used 0.305 Gas
-------------------------------------------------------------------------------------------------------------------------------------
Test invoke successful
Total operations: 320
Results [{'type': 'Integer', 'value': '8'}]
Invoke TX GAS cost: 0.0
Invoke TX fee: 0.0001
-------------------------------------------------------------------------------------------------------------------------------------
Enter your password to continue and invoke on the network
[password]>
Incorrect password
neo>
I suspect other reason. I confirm this bug occur in neo/Wallets/NEP5Token.py 99 line.
File "/home/ec2-user/venv/lib64/python3.6/site-packages/neo/Wallets/NEP5Token.py", line 101, in Query
engine = ApplicationEngine.Run(sb.ToArray(), exit_on_error=True, gas=Fixed8.FromDecimal(10.0), test_mode=False)
File "/home/ec2-user/venv/lib64/python3.6/site-packages/neo/SmartContract/ApplicationEngine.py", line 607, in Run
events.emit(event.event_type, event)
File "/home/ec2-user/venv/lib64/python3.6/site-packages/pymitter/__init__.py", line 282, in emit
remove = [l for l in listeners if not l(*args, **kwargs)]
File "/home/ec2-user/venv/lib64/python3.6/site-packages/pymitter/__init__.py", line 282, in <listcomp>
remove = [l for l in listeners if not l(*args, **kwargs)]
File "/home/ec2-user/venv/lib64/python3.6/site-packages/pymitter/__init__.py", line 310, in __call__
self.func(*args, **kwargs)
File "/home/ec2-user/venv/lib64/python3.6/site-packages/neo/EventHub.py", line 62, in on_sc_event
logger.info("[%s][%s] [%s] [tx %s] %s" % (sc_event.event_type, sc_event.block_number, sc_event.contract_hash, sc_event.tx_hash.ToString(), payload.ToJson(auto_hex=False)))
AttributeError: 'NoneType' object has no attribute 'ToString'
The error message doesn't give enough information to reproduce the error or solve the issue. All it says is that sc_event.tx_hash.ToString()
fails because tx_hash
is None
. Why that is, no clue.
I'd have to see the contract code in order to help you debug. We have many NEP5 tokens working just fine so that tells me there's something wrong with your code. Now to be fair, we should have better error handling and give a more useful message to the user. I'm willing to help on that but I need more information.
If it helps you can share the code privately (just DM me on discord, same name as here). You have to realise that all code on the blockchain is public. So keeping a contract secret isn't really helping you here, because the moment you publish it I can read the code (although only I assembly format). If it helps, you can just share the .avm
file (which are only the assembly instructions). That way I can't easily read your code, but I need something to reproduce the bug if you want my help.
Issue appears inactive. If you wish to continue the discussion please comment here and I'll re-open.
Current behavior
This is log. Default error message is "Could not import token" Error place is neo/Wallets/NEP5Token.py 99 line and I print this log.
I confirmed all nep5 methods and other my writing methods work expectedly.
Your environment