error when run transfer with eosjs
When I run test transfer from web page, will report error, here is my code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>EOS Test</title>
</head>
<body>
<h1>EOS JS Test</h1>
<p id="block">
</p>
<script src="eos.js"></script>
<script>
function testblock() {
var pp = '5JiJdyqw1iwNN3vZ1mHyYz1M4bZUiDEC6p1N7NDtwiEDc2bxzua'; // This is the private key of eosio.token
var eos = Eos.Localnet({keyProvider:pp}) ;
eos.transfer('eosio.token', 'poker', '1.0000 EOS', '', true) ;
}
</script>
<button type="button" onclick="testblock()">Test block</button>
</body>
</html>
When I click the button from web brower, will report error: api error => http://127.0.0.1:8888/v1/chain/push_transaction {"compression":"none","transaction":{"expiration":"2018-04-23T11:40:06","region":0,"ref_block_num":60334,"ref_block_prefix":744265118,"max_net_usage_words":0,"max_kcpu_usage":0,"delay_sec":0,"context_free_actions":[],"actions":[{"account":"eosio","name":"transfer","authorization":[{"actor":"eosio.token","permission":"active"}],"data":"00a6823403ea30550000000080ab20ad102700000000000004454f530000000000"}]},"signatures":["EOSK1RmSrpLzi4UsV2EA7FD9eC8Sp11Qieu3cyAWGs9HcwzxFpNjKxFNu6TSudyMdCAA8cx9Ayugf9Y6M93neU6AitYG7Kc85"]} Error: {"code":500,"message":"Internal Service Error","error":{"code":10,"name":"assert_exception","what":"Assert Exception","details":[{"message":"itr != structs.end(): Unknown struct ","file":"abi_serializer.cpp","line_number":184,"method":"get_struct"},{"message":"Failed to serialize type","file":"abi_serializer.hpp","line_number":439,"method":"to_variant"}]}} at eos.js:23172
+1 having the same error.
I indeed ran into this as well. It looks like transfer is pointing at the eosio account which is bios now.
Found the solution, you need to specify the currency contract and initiate a transaction from there. eos.transaction('currency', currency => { currency.transfer('inita', 'initb', '1 CUR', '') })
I think you have a version mis-match between eosjs and Localnet.. The unit tests in the eosjs/docker folder are passing. There is a simple version chart with links at the top of the README.md..
If your building yourself from eosio master it can of course break on you at anytime. The keep tags and branches though. I prefer docker, so much easier..
@jcalfee I run eos with version dawn-3.0, and eosjs with master branch(I cannot find dawn-3.0 eosjs).
Ok, let me try the docker, Thanks
@jcalfee I run lastest version eos(master) or run Docker with ./up.sh, same error occured. But ./run_test.sh can pass.
at process._tickCallback (internal/process/next_tick.js:188:7) status: 500, statusText: 'Internal Server Error' } [push_transaction error] '{"code":500,"message":"Internal Service Error","error":{"code":10,"name":"assert_exception","what":"Assert Exception","details":[{"message":"itr != structs.end(): Unknown struct ","file":"abi_serializer.cpp","line_number":184,"method":"get_struct"},{"message":"Failed to serialize type","file":"abi_serializer.hpp","line_number":439,"method":"to_variant"}]}}', transaction '10e6de5a0000be0394d91c1f00000000010000000000ea3055000000572d3ccdcd010000000000ea305500000000a8ed3232210000000000ea30550000000080ab20ad102700000000000004454f530000000000' {"code":500,"message":"Internal Service Error","error":{"code":10,"name":"assert_exception","what":"Assert Exception","details":[{"message":"itr != structs.end(): Unknown struct ","file":"abi_serializer.cpp","line_number":184,"method":"get_struct"},{"message":"Failed to serialize type","file":"abi_serializer.hpp","line_number":439,"method":"to_variant"}]}} (node:24471) UnhandledPromiseRejectionWarning: {"code":500,"message":"Internal Service Error","error":{"code":10,"name":"assert_exception","what":"Assert Exception","details":[{"message":"itr != structs.end(): Unknown struct ","file":"abi_serializer.cpp","line_number":184,"method":"get_struct"},{"message":"Failed to serialize type","file":"abi_serializer.hpp","line_number":439,"method":"to_variant"}]}}
Any idea ?
More information: eos@master, eosjs@dawn3
This might help (for testing only):
<script src="https://unpkg.com/[email protected]/dist/eos.js" />
Use ./up.sh in eosjs [master] and make sure the docker image eosio/eos:dawn3x is used.
I'll test eosio.token now.. I'll look at that now. They add new structs to nodeos that I need to sync with.
Looks like it is a version problem. I was able to deploy eosio.token using cleos then make a transfer like your example. I did upgrade some functions, lets go with [email protected] (i'll deploy shortly) ..
setup:
cleos create account eosio eosio.token EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
cleos set contract eosio.token contracts/eosio.token -p eosio.token@active
cleos push action eosio issue '{"to":"eosio.token", "quantity": "1000000000.0000 EOS", "memo": ""}' -p eosio@active
<script src="https://unpkg.com/[email protected]/dist/eos.js" />
> eos.transfer('eosio.token', 'inita', '1.0000 EOS', '', (err, res)=>{console.log(err,res)})
undefined
> null { transaction_id: '68dc224bc0b34500968148f13f1d49a1fd358e154885aed45f4498a145d3b35b',
broadcast: true,
transaction:
{ compression: 'none',
transaction:
{ expiration: '2018-04-24T17:15:25',
region: 0,
ref_block_num: 383,
ref_block_prefix: 160059228,
max_net_usage_words: 0,
max_kcpu_usage: 0,
delay_sec: 0,
context_free_actions: [],
actions: [Array] },
signatures: [ 'EOSK1eYuAbLz1pY4J1JKCB8dGrXPeaxP7wiVNhypoAJCXBUPNj28Xcts6ruqsdNWkaGQeNNZyhDKdchXouYKdQGo7aifhtVN6' ] } }
published [email protected]
@jcalfee Thanks, I will try asap.
@jcalfee did you submit last source code? I pull lastest source, still have same error. and https://unpkg.com/[email protected]/dist/eos.js cannot be access.
@jcalfee I follow you steps, now can transfer without errors, and can query the transfer transaction, but the user balance no change. any idea ?
function testEos() {
config = {
keyProvider: ['5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'], // WIF string or array of keys..
httpEndpoint: 'http://127.0.0.1:8888',
expireInSeconds: 60,
broadcast: true,
debug: false,
sign: true
}
var eos = Eos.Localnet(config);
eos.transfer('eosio', 'inita', '10 EOS', '', (err, res)=>{console.log(err,res)});
{transaction_id: "863d91727faf34f46399e93a293a21be2799535c513ad5a62875026c0b8dba41", broadcast: true, transaction: {…}}
cleos get transaction 863d91727faf34f46399e93a293a21be2799535c513ad5a62875026c0b8dba41
{
"transaction_id": "863d91727faf34f46399e93a293a21be2799535c513ad5a62875026c0b8dba41",
"transaction": {
"signatures": [
"EOSKBH73cAmQoPufAbuoQSYV6US4Pk6JVCLHHUmkGHjVaDgivuvd9L9wgc5jmAWP4hhwiMLQmd8syZpXZ4PjwHZaxNwqiAB8o"
],
"compression": "none",
"packed_context_free_data": "",
"context_free_data": [],
"packed_trx": "2048e15a00008744acd59d4100000000010000000000ea3055000000572d3ccdcd010000000000ea305500000000a8ed3232210000000000ea3055000000000093dd74a08601000000000004454f530000000000",
"transaction": {
"expiration": "2018-04-26T03:31:44",
"region": 0,
"ref_block_num": 17543,
"ref_block_prefix": 1100862892,
"max_net_usage_words": 0,
"max_kcpu_usage": 0,
"delay_sec": 0,
"context_free_actions": [],
"actions": [{
"account": "eosio",
"name": "transfer",
"authorization": [{
"actor": "eosio",
"permission": "active"
}
],
"data": {
"from": "eosio",
"to": "inita",
"quantity": "10.0000 EOS",
"memo": ""
},
"hex_data": "0000000000ea3055000000000093dd74a08601000000000004454f530000000000"
}
]
}
}
}
But query the inita balance, will return empty.
cleos get currency balance eosio.token inita
DAWN-2018-04-23-ALPHA (docker eosio/eos:DAWN-2018-04-23-ALPHA) fixes the get currency command. Eosjs 8.0.1 is compatible unless you get into the eosio.system calls.
I'll have a eosjs release for DAWN-2018-04-23-ALPHA today.
# eosio/eos:DAWN-2018-04-23-ALPHA
cleos get currency balance currency inita
982.0000 CUR
OK, let me try again, Thanks