why get table stat when do other aciton on myself contract??
use cleos push action OK, but :
eos.contract('xpa.ex').then(token => {
return token.deposit('w.1', '100.0000 SYS', '')
will return
FC Exception encountered while processing chain.get_currency_stats: 3060003 contract_table_query_exception: Contract Table Query Exception
Table stat is not specified in the ABI
{"table":"stat"}
thread-0 chain_plugin.cpp:522 get_table_type
why call the get_currency_stats API
method: 'get_table_type' } http://eos3:8888/v1/chain/get_currency_stats {"code":"xpa.ex","symbol":"XPA"}
[removed] .. still researching
I was able to create a token under another account using the eosio.token contract here: https://github.com/EOSIO/eosjs/blob/master/docker/up.sh#L47-L52
The stat table is part of the token contract and used to tell eosjs what the precision is for your asset. I think you'll need to implement that table.
@chris-allnutt can you confirm is the stat table part of our emerging token standard?
why eosjs do this? if your token symbol error, return error.
wangchh@XEPR03:~$ cleos push action xpa.ex deposit '["w.1", "100 XPA", ""]' -p w.1
Error 3050003: eosio_assert_message assertion failure
Error Details:
assertion failure with message: symbol precision mismatch
wangchh@XEPR03:~$ cleos push action xpa.ex deposit '["w.1", "100.0000 XPA", ""]' -p w.1
executed transaction: 1d77ea8c90ec92e499555292cd50ddf63625c35bac2d35629550709a492fd2c3 120 bytes 1405 us
# xpa.ex <= xpa.ex::deposit {"owner":"w.1","asset":"100.0000 XPA","memo":""}
# eosio.token <= eosio.token::transfer {"from":"w.1","to":"xpa.ex","quantity":"100.0000 XPA","memo":""}
# w.1 <= eosio.token::transfer {"from":"w.1","to":"xpa.ex","quantity":"100.0000 XPA","memo":""}
# xpa.ex <= eosio.token::transfer {"from":"w.1","to":"xpa.ex","quantity":"100.0000 XPA","memo":""}
warning: transaction executed locally, but may not be confirmed by the network yet
wangchh@XEPR03:~$
I also have this question... I have a completely different contract and structs but I'm using asset as a parameter of one of my actions and I think it triggers eosjs to check if it's a valid asset by checking the stats table of my contract (which I don't have, and also it does not make sense to).
The thing is, if I try to execute the same action through cleos it works perfectly, because I don't think cleos try to validate the asset and I think it's a task of the contract itself. Thoughts?
This behavior has been changed (fixed) in the latest version.. Assets and Symbols default to eosio.token .. If you have your own token contract use an extended_asset or extended_symbol..
I’m trying to adapt the issue action to use an extended_asset. the original issue action params body is:
{"to":"leo", "quantity": "100 TEST", "memo": "testing tokens"}
changed to extended_asset and tried the below parameters:
{"to":"leo", "quantity": {"amount": 100, "symbol": "TEST", "contract": "mytest"}, "memo": "testing tokens"}
But the extended asset is empty, like a brand new one, if I print it, this is what I have:
0.0000 SYS@mytest
So the contract is working but I’m not being able to set the amount and symbol. Any ideas?
I tried also "amount": "100 TEST" and also "asset": "100 TEST".. Nothing... Looks like I'm not being able to set the parent class (asset) attributes.
EDIT: looks like it's an issue, check https://github.com/EOSIO/eos/issues/3804
In eosjs, if the quantity is an extended_asset then its value is one string and with everything together: 0.0000 SYS@mytest..
The EOSIO/eos structs have support for this format to some degree. In the c++ code, will need to look into EOSLIB_SERIALIZE more to see how this is used:
EOSLIB_SERIALIZE( extended_asset, (amount)(symbol)(contract) )
Did you try to use cleos with 0.0000 SYS@mytest in the extended_asset parameter and worked? because for me it didn't
Yea, I can recreate the error now. The extended_asset in nodeos is looking at EOSLIB_SERIALIZE and expecting an object .. so I can change the json format eosjs is creating.
This is somewhat inconsistent for nodeos because the asset works as a string. Seems like the extended_asset should work as a string too..
published v14.1.1
Fixed extended_asset, it uses the json object format nodeos is expecting.
I have to refactor again .. Looks like you may not need extended_asset after all. Although it may not be a bad idea to use one, it will be very clear which contract the asset belongs too. I'll update this ticket with the progress: https://github.com/EOSIO/eosjs/issues/189