eosio / eosjs Goto Github PK
View Code? Open in Web Editor NEWGeneral purpose library for the EOSIO blockchain.
Home Page: http://eosio.github.io/eosjs
License: MIT License
General purpose library for the EOSIO blockchain.
Home Page: http://eosio.github.io/eosjs
License: MIT License
The following dawn2 Testnet endpoints are available:
Up until now we had only http .. This causes a problem in applications hosted over https because web pages should not mix http and https traffic. In this case requests to the eos node were blocked completely.
I propose that if an httpEndpoint is not provided to Eos.Testnet({..}) and the library is running in a browser, the current url protocol be tested and either the http or https url above be automatically selected. If eosjs is running elsewhere, https should be used.
This change needs to be tested from node and the browser.
related: https://github.com/EOSIO/eosjs-ui/issues/2
Error: only one instance of babel-polyfill is allowed
trying to run something like: (6.1.6)
node.transaction({
scope: ['inita', settings.rpc.account],
messages: [
{
code: settings.rpc.account,
type: 'tip',
authorization: [{
account: settings.rpc.account,
permission: 'active'
}],
data: {
from_twitter: "kesarito",
to_twitter: "kesarito2",
quantity: "0x0000000000000001"
}
}
]
});
getting:
Abi 'twitbot' is not cached, call abiAsync('twitbot') message.data transaction.messages
var options = {
broadcast: true,
sign: true,
scope: ['inita', settings.rpc.account],
messages: [
{
code: settings.rpc.account,
type: 'tip',
authorization: [{
account: settings.rpc.account,
permission: 'active'
}],
data: {
from_twitter: "kesarito",
to_twitter: "kesarito2",
quantity: 1
}
}
]
};
node.contract(settings.rpc.account).then(function (result) {
result.transaction(options);
});
Also fails getting:
Error: Required uint64 tip.2 message.data transaction.messages
Running it like:
var options = {
broadcast: true,
sign: true,
scope: ['inita', 'twitbot'],
authorization: [{
"account": "twitbot",
"permission": "active"
}]
};
var msg = {
"from_twitter": "kesarito",
"to_twitter": "kesarito2",
"quantity": "1"
}
node
.contract('twitbot', options)
.then((contract) => {
contract.tip(msg)
});
I get:
(node:29281) UnhandledPromiseRejectionWarning: TypeError: contract.tip is not a function
In command line this works:
eosioc push action twitbot tip '{"from_twitter": "kesarito", "to_twitter": "kesarito2", "quantity": 1}' --permission twitbot@active
ABI:
{
"types": [],
"structs": [{
"name": "account",
"base": "",
"fields": [{
"name": "twitter_account",
"type": "name"
},{
"name": "balance",
"type": "uint64"
}
]
},{
"name": "tip",
"base": "",
"fields": [
{"name":"from_twitter", "type":"name"},
{"name":"to_twitter", "type":"name"},
{"name":"quantity", "type":"uint64"}
]
},{
"name": "withdraw",
"base": "",
"fields": [
{"name":"to_eos", "type":"account_name"},
{"name":"from_twitter", "type":"name"}
]
}
],
"actions": [{
"name": "tip",
"type": "tip"
},{
"name": "withdraw",
"type": "withdraw"
}
],
"tables": [{
"name": "account",
"index_type": "i64",
"key_names": [
"twitter_account"
],
"key_types": [
"name"
],
"type": "account"
}
]
}
It seems that the lib is broken with the latest master of Eos.
I wanted to run all the integration tests to confirm but I could not find the documentation. How can I run them?
I noticed some tests are run only under certain conditions (
Line 49 in 3a76b24
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
for DAWN3:
i define my token: S(8, ZSH)
if i transfer my token, it will error, because "structs.js" set precision for 4
/** @example '0.0001 CUR' */
var symbolCache = function symbolCache(symbol) { return { precision: 4 }; };
still structs.js:
var prefix = '\x04'; // 4 decimals in EOS
Node version: v8.9.4
NPM version: 5.6.0
OS: Win7
EOS OS: Ubuntu 16.10 ( VM )
Something seems to have changed since version 6.1.0
regarding account creation.
Though I'm not sure if it's with eosjs itself, but perhaps a package it relies on as reverting to 6.1.0
after updating does not fix the issue. ( I had an older repo that worked, then I updated and no longer works ).
Other chain methods seem to work fine including transactions. In fact it doesn't seem to be hitting the EOS node at all when doing newaccount
Code used to produce
let eos = Eos.Localnet({httpEndpoint:`http://${network.host}:${network.port}`, keyProvider:'5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'});
eos.newaccount({
creator: 'inita',
name: 'tester',
owner: 'EOS7aewJRtiZfSfdzKZyuDMQEhreNXPgZsqMTmhZFGFqP3aXHZaFi',
active: 'EOS7aewJRtiZfSfdzKZyuDMQEhreNXPgZsqMTmhZFGFqP3aXHZaFi',
recovery: 'inita',
deposit: `1 EOS`
}).then(acc => {
console.log(acc);
})
Error:
struct.js:79 Error reading transaction.ref_block_num in data:
fromByteBuffer @ struct.js:79
fromBuffer @ fcbuffer.js:276
(anonymous) @ write-api.js:520
(anonymous) @ write-api.js:660
(anonymous) @ exported-helpers.js:65
(anonymous) @ exported-helpers.js:75
callback @ process-args.js:70
callback @ apigen.js:85
(anonymous) @ apigen.js:109
Promise resolved (async)
(anonymous) @ apigen.js:104
(anonymous) @ exported-helpers.js:54
(anonymous) @ exported-helpers.js:75
callback @ process-args.js:70
callback @ apigen.js:85
(anonymous) @ apigen.js:109
Promise resolved (async)
(anonymous) @ apigen.js:104
createTransaction @ exported-helpers.js:48
api.(anonymous function) @ apigen.js:38
transaction @ write-api.js:496
(anonymous) @ write-api.js:179
(anonymous) @ write-api.js:320
document.getElementById.addEventListener @ index-test.ts:39
bytebuffer.js:2795 ByteBufferAB(offset=2,markedOffset=-1,limit=194,capacity=194)
-------------------------------------------------------------------
97 04<3E DA D9 86 B0 90 7F 5A 01 00 00 00 00 00 ..>......Z......
93 DD 74 00 01 00 00 00 00 00 00 30 55 00 40 9E ..t........0U.@.
9A 22 64 B8 9A 01 00 00 00 00 00 93 DD 74 00 00 ."d..........t..
00 00 A8 ED 32 32 8A 01 00 00 00 00 00 93 DD 74 ....22.........t
00 00 00 40 5C 95 B1 CA 01 00 00 00 01 03 62 97 ...@\.........b.
9E 69 82 84 0E 3A D5 A3 11 C0 8D 04 6A A9 18 03 .i...:......j...
81 A6 60 10 18 C6 80 45 B7 C6 01 B5 5E 23 01 00 ..`....E....^#..
00 01 00 00 00 01 03 62 97 9E 69 82 84 0E 3A D5 .......b..i...:.
A3 11 C0 8D 04 6A A9 18 03 81 A6 60 10 18 C6 80 .....j.....`....
45 B7 C6 01 B5 5E 23 01 00 00 01 00 00 00 00 01 E....^#.........
00 00 00 00 00 93 DD 74 00 00 00 00 A8 ED 32 32 .......t......22
01 00 10 27 00 00 00 00 00 00 04 45 4F 53 00 00 ...'.......EOS..
00 00> ..
apigen.js:111 Error: Assertion failed (transaction.ref_block_num) transaction.ref_block_num
at assert (bn.js:6)
at BN._initArray (bn.js:145)
at BN.init [as _init] (bn.js:82)
at new BN (bn.js:39)
at Object.fromByteBuffer (types.js:476)
at Object.fromByteBuffer (struct.js:66)
at Function.fromBuffer (fcbuffer.js:276)
at write-api.js:520
at write-api.js:660
at exported-helpers.js:65
Example eosjs document change:
Eos = require('eosjs') // Eos = require('./src')
// Optional configuration..
config = {
httpEndpoint: 'http://127.0.0.1:8888',
mockTransactions: () => 'pass', // or 'fail'
transactionHeaders: () => {
ref_block_num,
ref_block_prefix,
expiration
},
expireInSeconds: 60,
broadcast: true,
debug: false,
sign: true
}
eos = Eos.Localnet(config)
* mockTransactions (optional)
* `pass` - do not broadcast, always pretend that the transaction worked
* `fail` - do not broadcast, pretend the transaction failed
* `null|undefined` - broadcast as usual
* transactionHeaders (optional) - alternative transaction header provider. This
may be provided so eosjs does not need to make header related API calls to
eosd.
transactionHeaders will link to a new jsdoc markdown in eosjs-api:
Name | Type | Description |
---|---|---|
ref_block_num | number | Recent head block number (ideally last irreversible block). The bit-wise AND operation is used to keep this value with the size of a Uint16 size. Example:(get_info.head_block_num - 3) & 0xFFFF |
ref_block_prefix | string | get_block.ref_block_prefix .. This is the same block referenced in ref_block_num. |
expiration | string | This is based on the head block time from the blockchain. Be careful to suffix a Z if required (as with Firefox and JavaScript) to ensure this date string is interpreted as Zulu time. Example: new Date(info.head_block_time + 'Z').getTime() + expireInSeconds * 1000 |
when run "eos.setcode" , it occurs error as title๏ผ
Error: maxLen validation requries a "length" property struct_t.fields abi.structs setcode.code_abi message.data transaction.messages
at validate (/usr/local/eosjs-master/node_modules/fcbuffer/lib/types.js:663:13)
at Object.fromObject (/usr/local/eosjs-master/node_modules/fcbuffer/lib/types.js:570:7)
at Object.fromObject (/usr/local/eosjs-master/node_modules/fcbuffer/lib/types.js:234:45)
at Object.fromObject (/usr/local/eosjs-master/node_modules/fcbuffer/lib/struct.js:144:34)
at Object.fromObject (/usr/local/eosjs-master/node_modules/fcbuffer/lib/types.js:320:28)
at Object.fromObject (/usr/local/eosjs-master/node_modules/fcbuffer/lib/struct.js:144:34)
at Object.fromObject (/usr/local/eosjs-master/node_modules/fcbuffer/lib/struct.js:144:34)
at message.data.fromObject (/usr/local/eosjs-master/src/structs.js:333:27)
at Object.fromObject (/usr/local/eosjs-master/node_modules/fcbuffer/lib/struct.js:141:15)
at Object.fromObject (/usr/local/eosjs-master/node_modules/fcbuffer/lib/types.js:320:28)
api error => http://127.0.0.1:8888/v1/chain/push_transaction {"compression":"none","data":{"expiration":"2018-04-06T22:46:23","region":0,"ref_block_num":3721,"r
ef_block_prefix":2640367696,"packed_bandwidth_words":11,"context_free_cpu_bandwidth":0,"context_free_actions":[],"actions":[{"account":"eosio","name":"transfer"
,"authorization":[{"actor":"tester","permission":"active"}],"data":"000000005c95b1ca00000000007015d6701101000000000004454f530000000000"}]},"signatures":["EOSK9x
B3Vp7fAp7NGNN1TiXaAVRtqTafMuFKTnWDvKHaUV8zqKXk53BjewByE7m8p7hBGSZTPvqc5MhSDRL5AyYDHvtCEdv9m"]} { Error: {"code":500,"message":"Internal Service Error","error":{
"code":3120010,"name":"packed_transaction_type_exception","what":"Invalid packed transaction","details":[{"message":"Missing transaction","file":"abi_serializer
.hpp","line_number":367,"method":"extract"},{"message":"Failed to deserialize variant","file":"abi_serializer.hpp","line_number":444,"method":"from_variant"},{"
message":"Invalid packed transaction","file":"chain_plugin.cpp","line_number":414,"method":"push_transaction"}]}}
at /home/vagrant/test/node_modules/eosjs-api/lib/apigen.js:98:23
at
at process._tickCallback (internal/process/next_tick.js:188:7) status: 500, statusText: 'Internal Server Error' }
{ Error: {"code":500,"message":"Internal Service Error","error":{"code":3120010,"name":"packed_transaction_type_exception","what":"Invalid packed transaction","
details":[{"message":"Missing transaction","file":"abi_serializer.hpp","line_number":367,"method":"extract"},{"message":"Failed to deserialize variant","file":"
abi_serializer.hpp","line_number":444,"method":"from_variant"},{"message":"Invalid packed transaction","file":"chain_plugin.cpp","line_number":414,"method":"pus
h_transaction"}]}}
at /home/vagrant/test/node_modules/eosjs-api/lib/apigen.js:98:23
at
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":3120010,"name":"packed_transaction_type_exception","what":"Invalid pack
ed transaction","details":[{"message":"Missing transaction","file":"abi_serializer.hpp","line_number":367,"method":"extract"},{"message":"Failed to deserialize
variant","file":"abi_serializer.hpp","line_number":444,"method":"from_variant"},{"message":"Invalid packed transaction","file":"chain_plugin.cpp","line_number":
414,"method":"push_transaction"}]}}', transaction 'bff8c75a0000890e50d0609d0b00000000010000000000ea3055000000572d3ccdcd01000000005c95b1ca00000000a8ed32322100000
0005c95b1ca00000000007015d6701101000000000004454f530000000000'
{"code":500,"message":"Internal Service Error","error":{"code":3120010,"name":"packed_transaction_type_exception","what":"Invalid packed transaction","details":
[{"message":"Missing transaction","file":"abi_serializer.hpp","line_number":367,"method":"extract"},{"message":"Failed to deserialize variant","file":"abi_seria
lizer.hpp","line_number":444,"method":"from_variant"},{"message":"Invalid packed transaction","file":"chain_plugin.cpp","line_number":414,"method":"push_transac
tion"}]}}
(node:6626) UnhandledPromiseRejectionWarning: {"code":500,"message":"Internal Service Error","error":{"code":3120010,"name":"packed_transaction_type_exception",
"what":"Invalid packed transaction","details":[{"message":"Missing transaction","file":"abi_serializer.hpp","line_number":367,"method":"extract"},{"message":"Fa
iled to deserialize variant","file":"abi_serializer.hpp","line_number":444,"method":"from_variant"},{"message":"Invalid packed transaction","file":"chain_plugin
.cpp","line_number":414,"method":"push_transaction"}]}}
(node:6626) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch
block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6626) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the
Node.js process with a non-zero exit code.
Hi James and Chris. Great work on putting this library together...I'm trying to publish a contract using the Dawn3 eosjs release and getting wasm errors. I'm using the boilerplate code on the readme - pulling in the individual files with fs and using binaryen.
Specifically, I'm running the Dawn3 release on Ubuntu 16.04 (not with Docker) and I can publish all contracts via cleos, but not with the eosjs@dawn3 api. I've tried simplifying with just the hello-world contracts on the eosio wiki and still get an error. Is the format for setcode() with eosjs@dawn3 the same as dawn2? It looks like cleos in Dawn3 now seems to only require a folder 'cleos set contract hello.code ../hello -p hello.code' and not the actual files?
contractDir = `${process.env.HOME}/eosio/dawn3/build/contracts/currency`
wast = fs.readFileSync(`${contractDir}/currency.wast`)
abi = fs.readFileSync(`${contractDir}/currency.abi`)
// Publish contract to the blockchain
eos.setcode('currency', 0, 0, wast)
eos.setabi('currency', JSON.parse(abi))
Here's the error
Assembling WASM...
[parse exception: expected list (at 267:18)]Fatal: error in parsing wasm text
Do you have any documentation or insight that could help? Thanks so much in advance for all the great work on this library.
When a keyProvider has multiple keys available it will start using the get_required_keys API call.
Ensure all types (like the public key) have a comparison operator. This ensures consistent matching serialization and signatures.
I want to use emails or numeric id as usernames but there are restrictions while account creating like this: 'A name can be up to 13 characters long' or 'Invalid character' except '.12345abcdefghijklmnopqrstuvwxyz'. Any way to bypass that?
as subject
When building a React application created with create-react-app
and adding eosjs 6.1.8 as a dependency, building the app (npm run build
) results in the following error:
root@blockone:~/block.one# npm run build
> [email protected] build /root/block.one
> react-scripts build
Creating an optimized production build...
Failed to compile.
Failed to minify the code from this file:
./node_modules/eosjs/lib/write-api.js:98
Read more here: http://bit.ly/2tRViJ9
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-03-11T14_53_14_563Z-debug.log
This is happening because the compiled version of eosjs 6.1.8 (shipped via npm) still has an async
keyword in the ES5 version of the code. The line in question is
Line 82 in 3dbee24
Forcing the build to use eosjs 6.1.6 fixes the issue.
let testNewAccount = async () => {
let adminPrivate = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3";
config.keyProvider = [adminPrivate];
let eos = Eos.Localnet(config);
const pubkey = 'EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV';
try {
let res = await eos.newaccount({
creator: 'inita',
name: 'initzsh',
owner: pubkey,
active: pubkey,
recovery: 'inita',
deposit: '1.0000 EOS'
});
console.log("res", res);
return res;
} catch (err) {
console.log("err", err);
return err;
}
};
{
"transaction_id": "3b99204c9c817b1312419f7eb2c2503a918610403acb9d07346c016e02a02f2b",
"broadcast": false,
"transaction": {
"compression": "none",
"data": {
"expiration": "2018-03-24T06:51:24",
"region": 0,
"ref_block_num": 21814,
"ref_block_prefix": 1849637573,
"packed_bandwidth_words": 23,
"context_free_cpu_bandwidth": 0,
"context_free_actions": [],
"actions": [
{
"account": "eosio",
"name": "newaccount",
"authorization": [
{
"actor": "inita",
"permission": "active"
}
],
"data": "000000000093dd74000000a0e19fdd740100000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf01000100000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf01000100000001000000000093dd7400000000a8ed3232010000"
}
]
},
"signatures": [
"EOSK4Sn3XmoTFDED3sgghhinwDVV6NtF42zP6LECDPCPufgctfJW9znWAnPh3tz4ibPS8r9e1fo68jcJmxuv73pQ6uoT8zkGr"
]
}
}
eos git:(master) cleos get account initzsh
{
"account_name": "initzsh",
"permissions": []
}
The following command works perfectly
cleos push action inventory insertinvent '["richard","laptop"]' -p richard
what is the equivalent eosjs call?
const msg = {
status:'["richard","laptop"]'
}
eos
.contract('inventory')
.then((contract) => {
contract.insertinvent(msg, { scope: 'inventory', authorization: [{account: 'richard', permission: 'active'}] })
})
Fails with
TypeError: name parameter is a required string permission_level.actor = undefined action.authorization = [{"permission":"active"}]
when I use eosjs-7.1.1 , run " eos.setcode('xx', 0, 0, wast, abi); " to deploy contract๏ผ it occurs errors as title
I use this.eos = Eos.Testnet();
as per README, but it tries to connect to localhost.
{ FetchError: request to http://127.0.0.1:8888/v1/chain/get_block failed, reason: connect ECONNREFUSED 127.0.0.1:8888
Or do I have to run eosc and eos_walletd locally and point that one against testnet1?
This works however:
const config = {
httpEndpoint: 'http://testnet1.eos.io'
};
Would be great to clarify this and a bit more context (in the README?) even if trivial problem.
It seems that with the latest dawn3 version ( 8.0.0
) using contract()
does not gather authorizations into the actions
array.
For instance this:
eos.contract('anything').then(contract => {
contract.hello(...paramWithRequiredAccount)
});
returns
{"code":400,"message":"Bad Request",
"error":{"code":3030033,"name":"tx_no_auths",
"what":"transaction should have at least one required authority",........
because the actions array looks like:
[{
account:"anything"
authorization:[]
data:"10e874ed4a9aa6b9f00000000..."
name:"hello"
}]
However when explicitly specifying the accounts, this works:
eos.contract('anything').then(contract => {
const options = { authorization: [ `someacc@active` ] };
contract.hello(...paramWithRequiredAccount, options)
});
After I deployed the eosio.bios
contract, I try to execute setpriv
action.
eos.contract('eosio').then(function (contract) {
contract.setpriv('eosio', 1, { authorization: 'eosio' });
});
Then jump out of the exception:
TypeError: Expecting hex string or buffer in action.data action.data = {"account":"eosio","is_priv":1} transaction.actions = [{"account":"eosio","name":"setpriv","authorization":[{"actor":"eosio","permission":"active"}],"data":{"account":"eosio","is_priv":1}}]
at actionDataAppendByteBuffer (/Users/shrimp/work/eos-boot-sim/node_modules/eosjs/lib/structs.js:535:17)
at Object.appendByteBuffer (/Users/shrimp/work/eos-boot-sim/node_modules/fcbuffer/lib/struct.js:108:15)
at Object.appendByteBuffer (/Users/shrimp/work/eos-boot-sim/node_modules/fcbuffer/lib/types.js:350:16)
at Object.appendByteBuffer (/Users/shrimp/work/eos-boot-sim/node_modules/fcbuffer/lib/struct.js:110:20)
at toByteBuffer (/Users/shrimp/work/eos-boot-sim/node_modules/fcbuffer/lib/fcbuffer.js:284:8)
at Function.toBuffer (/Users/shrimp/work/eos-boot-sim/node_modules/fcbuffer/lib/fcbuffer.js:271:22)
at /Users/shrimp/work/eos-boot-sim/node_modules/eosjs/lib/write-api.js:611:26
at /Users/shrimp/work/eos-boot-sim/node_modules/eosjs/lib/write-api.js:766:7
at /Users/shrimp/work/eos-boot-sim/node_modules/eosjs-api/lib/exported-helpers.js:69:7
at /Users/shrimp/work/eos-boot-sim/node_modules/eosjs-api/lib/exported-helpers.js:79:7
Error is located here in file eosjs/lib/structs.js
:
var data = typeof object.data === 'string' ? new Buffer(object.data, 'hex') : object.data;
if (!Buffer.isBuffer(data)) {
throw new TypeError('Expecting hex string or buffer in action.data');
}
Do you have any documentation or insight that could help?
Needed functions for:
My target is to make an app that can be html or native. For now let it be web app. I have deployed a hello world contract in my local blockchain network. I have defined a function named "hi". I need to call this function from my web app through js and I'm using eosjs in browserify. Can anyone guide me through this ? It would be great if anyone can give me a solution here.
The fs npm module is stopped their service. They are saying,
This package name is not currently in use, but was formerly occupied by another package. To avoid malicious use
So how to read abi and wast file from node ?
contractDir = ${process.env.HOME}/eosio/eos/build/contracts/currency
wast = fs.readFileSync(${contractDir}/currency.wast
)
abi = fs.readFileSync(${contractDir}/currency.abi
)
Please help
Add configuration option to all networks: Testnet, Localnet, Prodnet, etc.. called mockTransactions
.
Usage: Eos.Testnet({mockTransactions: () => 'pass|fail|null'})
.
pass
- do not broadcast, always pretend that the transaction workedfail
- do not broadcast, pretend the transaction failednull|undefined
- broadcast as usualAll transaction writes will respond to this setting (example: newaccount). All transaction reads will be unaffected (example: getBlock).
The following changes are needed to reorganize eosjs branches into a familiar format (like eosio/eos):
Here is a table for the README.md:
Version | EOSIO/eosjs | Npm | EOSIO/eos | Docker | Node |
---|---|---|---|---|---|
dawn3 | branch: master | npm install eosjs@dawn3 |
branch: master | eosio/eos:latest | local docker |
dawn2 | branch: dawn2 | npm install eosjs |
branch: dawn-2.x | eosio/eos:dawn2x | http or https://t1readonly.eos.io |
The latest Eos.Testnet() points to a http://testnet1.eos.io which is not accepting CORS requests yet. So it works in node but not in the browser.
In the mean time: http://t1readonly.eos.io is setup with CORS. I'm told it will however silently fail if a large smart contract (setcode) is attempted.
babel-preset-es2015 update to env
"babel-preset-env": "^1.6.1",
"babel-preset-stage-2": "^6.24.1",
{
"presets": ["env", "stage-2"],
"plugins": []
}
โ eosjs git:(master) โ ncu
Using /Users/testeos/node_modules/eosjs/package.json
โธจโโโโโโโโโโโโโโโโโโโธฉ โ :
binaryen ^37.0.0 โ ^44.0.0
browserify ^14.4.0 โ ^16.1.1
coveralls ^2.13.1 โ ^3.0.0
jsdoc-to-markdown ^3.0.4 โ ^4.0.1
mocha ^3.4.2 โ ^5.0.5
The following dependencies are satisfied by their declared version range, but the installed versions are behind. You can install the latest versions without modifying your package file by using npm update. If you want to updatethe dependencies in your package file anyway, run ncu -a.
eosjs-keygen ^1.2.0 โ ^1.3.0
nyc ^11.4.1 โ ^11.6.0
Run ncu with -u to upgrade package.json
yesterday, i had solved newaccount's error on my imac with the help of chris-allnutt. @chris-allnutt
today, in my macbookpro, newaccount can't run correctly.
i try to repull the code and rebuild:
git clone https://github.com/eosio/eos --recursive
cd eos
./eosio_build.sh
cd build && sudo make install
i use the same file(config.ini&genesis.json) with my imac.
but the result is incorrect on my macbookpro.
let testNewAccount = async () => {
let initaPrivate = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3";
let initaPublic = "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV";
let keyProvider = initaPrivate;
let eos = Eos.Localnet({ keyProvider });
try {
let res = await eos.newaccount({
creator: "eosio",
name: "mynewacct",
owner: initaPublic,
active: initaPublic,
recovery: "eosio",
deposit: "1 EOS"
}, { broadcast: true });
console.log("res", res);
return res;
} catch (err) {
console.log("err", err);
return err;
}
};
api error => http://127.0.0.1:8888/v1/chain/push_transaction {"compression":"none","data":{"expiration":"2018-03-27T05:26:09","region":0,"ref_block_num":491,"ref_block_prefix":1476926362,"packed_bandwidth_words":23,"context_free_cpu_bandwidth":0,"context_free_actions":[],"actions":[{"account":"eosio","name":"newaccount","authorization":[{"actor":"eosio","permission":"active"}],"data":"0000000000ea30550000c80819aea6970100000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf01000100000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf010001000000010000000000ea305500000000a8ed3232010000"}]},"signatures":["EOSK7E7u5Q484VDzZiFqSGTF6xB6DB8mzss3nu66FgQkRwFxAbxgbF3nWg2JrhHfuPEXXh5f17JByQahJ4zpMJqrkwEHYiSvJ"]} { Error: {"code":500,"message":"InternalService Error","error":{"code":10,"name":"assert_exception","message":"Assert Exception","details":"w < count(): ","stack_trace":[{"level":"error","file":"static_variant.hpp","line":344,"method":"set_which","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":327,"method":"operator()","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":568,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":327,"method":"operator()","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":568,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":327,"method":"operator()","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":568,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":327,"method":"operator()","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":568,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":614,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"}]}}
at /Users/zshchou/Projects/inkeos/node_modules/eosjs-api/lib/apigen.js:98:23
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:118:7) status: 500, statusText: 'Internal Server Error' }
{ Error: {"code":500,"message":"Internal Service Error","error":{"code":10,"name":"assert_exception","message":"Assert Exception","details":"w < count(): ","stack_trace":[{"level":"error","file":"static_variant.hpp","line":344,"method":"set_which","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":327,"method":"operator()","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":568,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":327,"method":"operator()","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":568,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":327,"method":"operator()","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":568,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":327,"method":"operator()","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":568,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":614,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"}]}}
at /Users/zshchou/Projects/inkeos/node_modules/eosjs-api/lib/apigen.js:98:23
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:118:7) status: 500, statusText: 'Internal Server Error' }
[push_transaction error] '{"code":500,"message":"Internal Service Error","error":{"code":10,"name":"assert_exception","message":"Assert Exception","details":"w < count(): ","stack_trace":[{"level":"error","file":"static_variant.hpp","line":344,"method":"set_which","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":327,"method":"operator()","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":568,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":327,"method":"operator()","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":568,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":327,"method":"operator()","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":568,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":327,"method":"operator()","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":568,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":614,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"}]}}', transaction 'f1d5b95a0000eb019a1b08581700000000010000000000ea305500409e9a2264b89a010000000000ea305500000000a8ed32327c0000000000ea30550000c80819aea6970100000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf01000100000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf010001000000010000000000ea305500000000a8ed3232010000'
{"code":500,"message":"Internal Service Error","error":{"code":10,"name":"assert_exception","message":"Assert Exception","details":"w < count(): ","stack_trace":[{"level":"error","file":"static_variant.hpp","line":344,"method":"set_which","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":327,"method":"operator()","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":568,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":327,"method":"operator()","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":568,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":327,"method":"operator()","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":568,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":327,"method":"operator()","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":568,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"},{"level":"warn","file":"raw.hpp","line":614,"method":"unpack","hostname":"","thread_name":"thread-0","timestamp":"2018-03-27T05:25:09.743"}]}}
You can use inheritance in EOS abi, like so:
structs: [
{
"name": "action1",
"base": "",
"fields": {
"field1": "string",
"field2": "string"
}
},{
"name": "action2",
"base": "action1",
"fields": {
"field3": "account_name",
}
]
"actions": [
"action_name": "action1",
"type": "action1"
},{
"action_name": "action2",
"type": "action2"
}
]
I would expect to be able to use contract with this abi like this:
eos.contract('contr').then( c => { c.action2("1", "2", "3" });
But then I get this error:
Uncaught TypeError: action2 is expecting 1 parameters but 3 where provided
Add: if only 1 key is available it will simply sign the transaction without talking to the blockchain
Existing behavior will be kept when the user provides more than one private key to eosjs:
The default sign provider is designed to interact with the available public keys (maybe just one), the transaction and blockchain to figure out the minimum set of signing keys. Providing a custom signProvider skips that process.
Skipping this process when eosjs has 1 key changes the error message if the wrong key is used to sign a transaction. It will of course reject, just a bit later from eos. This overall improves efficiency and removes complexity, most transactions will pass.
I propose this as a patch..
Trying out below code and it shows the error
TypeError: Cannot read property 'split' of undefined newaccount.deposit = undefined
Running:
npm install eosjs
Dawn 3 EOS
========== index.js
Eos = require('eosjs') // Eos = require('./src')
eosioprivate = '5JeeZ6atfR...'
eosiopublic = 'EOS5gx8uqfz...'
// Optional configuration..
config = {
httpEndpoint: 'http://127.0.0.1:8888',
keyProvider: eosioprivate,
}
eos = Eos.Localnet(config)
eos.newaccount({
creator: 'eosio',
name: 'testa',
owner: eosiopublic,
active: eosiopublic,
recovery: 'eosio'
deposit: 0
})
I've deployed the tic tac toe example and am now trying to create a new game with eosjs
, but I'm getting errors about irrelevant authorities?
Here's the code I'm trying to run:
eos.contract('tictactoe').then(c => c.create({ host: 'inita', challenger: 'initb' }))
But when I run that I get these errors:
Here's the payload for that push_transaction
request:
{
"ref_block_num":8158,
"ref_block_prefix":1085591932,
"expiration":"2017-11-23T08:13:11",
"scope":[
"inita",
"initb"
],
"read_scope":[
],
"messages":[
{
"code":"tictactoe",
"type":"create",
"authorization":[
{
"account":"initb",
"permission":"active"
}
],
"data":{
"challenger":"initb",
"host":"inita"
}
}
],
"signatures":[
"1f5d41e3077f3d71b0155203a62d4ab86317cd8bbedb48f37b12471e0da0bdb1111852576e65fa9ffbaf860969f363b280b9971ce5c7012e84edcc002e2de33cf9"
]
}
I also tried creating the transaction manually like this:
eos.transaction({
scope: ['inita', 'initb'],
messages: [
{
code: 'tictactoe',
type: 'create',
authorization: [],
data: {
host: 'inita', challenger: 'initb'
}
}
]
})
But then I get different errors about missing required keys:
Any idea what's causing this? Am I doing something wrong? Thanks.
eosio version: dawn-v3.0.0 (d9ad8ee)
eosjs version: 7.1.5 (a148dc8)
Test code:
Eos = require('../src') //Eos = require('eosjs')
eos = Eos.Localnet() // eos = Eos.Testnet() // testnet at eos.io
eos.getBlock()
Error message:
$ node app/test.js
/home/joel/eosjs/src/structs.js:117
const staticVariant = baseTypes.static_variant([
^
TypeError: baseTypes.static_variant is not a function
at PublicKeyType (/home/joel/eosjs/src/structs.js:117:35)
at createType (/home/joel/eosjs/node_modules/fcbuffer/lib/types.js:161:14)
at customTypes.(anonymous function) (/home/joel/eosjs/node_modules/fcbuffer/lib/types.js:132:20)
at getTypeOrStruct (/home/joel/eosjs/node_modules/fcbuffer/lib/fcbuffer.js:160:13)
at create (/home/joel/eosjs/node_modules/fcbuffer/lib/fcbuffer.js:198:16)
at module.exports (/home/joel/eosjs/node_modules/fcbuffer/lib/index.js:51:17)
at module.exports (/home/joel/eosjs/src/structs.js:74:58)
at createEos (/home/joel/eosjs/src/index.js:76:50)
at Object.Localnet (/home/joel/eosjs/src/index.js:52:12)
at Object.<anonymous> (/home/joel/eosjs/app/test.js:2:11)
Hi James,
with the latest version I still run into issues. Getting an instance of the exchange
contract works for me, but sending the message does not.
const options = {
broadcast: true,
sign: true,
scope: [
"exchange"
],
authorization: [{
"account": "inita",
"permission": "active"
}]
}
const msg = {
"buyer":{ "name": "inita", "number": "1516073924"},
"at_price":"5000000000000000",
"expiration":"2018-12-31T23:59:59",
"quantity": "100",
"fill_or_kill": "0"
}
eos
.contract('exchange', options)
.then((contract) => {
contract.buy(msg)
})
results in:
TypeError: Invalid character: '_' message.type = "buy_order" transaction.messages = [{"code":"exchange","type":"buy_order","authorization":[],"data":{"buyer":{"name":"inita","number":"1516073924"},"at_price":"5000000000000000","quantity":"100","expiration":1546300799,"fill_or_kill":"0"}}]
at charidx (/Users/robert/test/node_modules/eosjs/lib/format.js:61:25)
at encodeName (/Users/robert/test/node_modules/eosjs/lib/format.js:90:31)
at Object.appendByteBuffer (/Users/robert/test/node_modules/eosjs/lib/structs.js:97:21)
at Object.appendByteBuffer (/Users/robert/test/node_modules/fcbuffer/lib/struct.js:103:20)
at Object.appendByteBuffer (/Users/robert/test/node_modules/fcbuffer/lib/types.js:292:16)
at Object.appendByteBuffer (/Users/robert/test/node_modules/fcbuffer/lib/struct.js:103:20)
at toByteBuffer (/Users/robert/test/node_modules/fcbuffer/lib/fcbuffer.js:282:8)
at Function.toBuffer (/Users/robert/test/node_modules/fcbuffer/lib/fcbuffer.js:269:22)
at /Users/robert/test/node_modules/eosjs/lib/write-api.js:519:26
at /Users/robert/test/node_modules/eosjs/lib/write-api.js:660:7
does the exchange contract work for you?
related: #49 EOSIO/eosjs-api#5
I think adding an optional code hash verification would be good feature to have.
So when i do a eos.contract(code<string>, [options], [callback])
i could also pass in a hash that the code hash has to match.
Maybe like this eos.contract(code<string>, {hash:some_hash}, [callback])
I'm trying to create a new account with eosjs using eos.newaccount
, but I keep getting errors like this:
This screenshot is from a Browserified bundle in Chrome, but I see the same errors in a Node REPL.
Here's the code snippet I'm trying to run (from the README):
Eos = require('eosjs') // Or Eos = require('./src')
initaPrivate = '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'
initaPublic = 'EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV'
keyProvider = initaPrivate
eos = Eos.Testnet({keyProvider})
eos.newaccount({
creator: 'inita',
name: 'mynewacct',
owner: initaPublic,
active: initaPublic,
recovery: 'inita',
deposit: '1 EOS'
})
My local eos
repo is at commit ec638a089f1e195fa83bfe5b0c8f677d04fae9a8
(latest from master as of last night) and I'm running it from the Docker image.
I'm using eosjs
v4.0.1 (latest from NPM).
Please let me know if you need any more information. Thanks!
version:"eosjs": "^7.1.6",
problem:
apigen.js?f08d:115 Error: Required uint16 transaction_header.packed_bandwidth_words transaction.
apigen.js?f08d:115 Error: Required uint16 transaction_header.context_free_cpu_bandwidth transaction.
des: these two attributes are not exist;so I add them in the js code(write-api.js) like this:
rawTx.packed_bandwidth_words=0;
rawTx.context_free_cpu_bandwidth= 0;
then I refresh the quest,get nothing response (no error tips )
here is my code :
var config = {
keyProvider: ['5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'] ,// WIF string or array of keys..
httpEndpoint: 'http://127.0.0.1:8888',
mockTransactions: () => 'pass',
expireInSeconds: 100,
broadcast: true,
debug: false,
sign: true
};
var eos = Eos.Localnet(config);
eos.newaccount({
creator: 'eosio',
name:'testaccount',
owner: 'EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV',
active: 'EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV',
recovery: 'eosio'
});
const config = {
keyProvider: ['5KidmFeAxac6F2LMrkf43LjqhhVGDnPXkq33ZvJ3uRugbbLQiU4', '5JC9emfULeVp3H5RMWoo4Qe8tiajcnHhwG4pVbbjR8exHBC1vWm'], // WIF string or array of keys..
httpEndpoint: 'http://127.0.0.1:8888',
expireInSeconds: 60
};
const eos = Eos.Localnet(config);
console.log(eos.getBlock());
eos.contract('currency').then(currency => {
currency.transfer('navcs', 'currency', '1.00000000 LCCC', 'Eosjs test').then(result => {
console.log(result);
console.log('transfer success');
}).catch(error => {
console.log(error);
console.log('transfer error');
});
});
Param quantity
in above request is 1.00000000 LCCC
. It will have symbol is S(8, LCCC)
but on the server EOS I receive S(4, LCCC)
!
So I can not query correct balance of account ๐
When I use "7aefccc 6.1.11" of eosjs with hello world smart contract, there is an error as following:
initialised helloworld
(node:20693) UnhandledPromiseRejectionWarning: ReferenceError: headers is not defined
at transactionHeaders (/home/joel/eosjs/app/hello.js:13:29)
at transaction (/home/joel/eosjs/src/write-api.js:416:5)
at Object.transaction (/home/joel/eosjs/src/write-api.js:147:14)
at
at process._tickCallback (internal/process/next_tick.js:160:7)
(node:20693) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
Heya,
I am trying to interact with a custom contract (exchange)
.
Using the CLI eosc
all works well, example message:
eosc push message exchange buy '{"buyer":{ "name": "inita", "number": "1516073924"}, "at_price":"5000000000000000", "expiration":"2018-12-31T23:59:59" , "quantity": "100", "fill_or_kill": "0"}' -S exchange -p inita@active
To me it seems the eosjs APIs are not supporting interactions like this yet - or I am using it wrong.
This code:
const eos = eos.Localnet({
keyProvider: '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'
})
const options = {
broadcast: true,
sign: true,
scope: [
"exchange"
],
authorization: [{
"account": "inita",
"permission": "active"
}]
}
eos
.contract('exchange', options)
.then((exchange) => {
console.log(exchange)
console.log("initialised exchange")
})
Throws with
Error: [
"Missing uint128 in bid.fields.at_price",
"Missing uint128 in ask.fields.at_price"
]
It seems to interact with the contract (missing fields), which puzzles me. Any ideas?
When I try to send a message directly without using the contract function, I run into a cache issue:
const msg = {"buyer":{ "name": "inita", "number": "1516073924"}, "at_price":"5000000000000000", "expiration":"2018-12-31T23:59:59" , "quantity": "100", "fill_or_kill": "0"}
eos.transaction({
scope: ['inita', 'initb', 'exchange'],
messages: [
{
code: 'exchange',
type: 'buy',
authorization: [{
account: 'inita',
permission: 'active'
}],
data: msg
}
]
})
results in:
Error: Abi 'exchange' is not cached, call abiAsync('exchange') message.data transaction.messages
I tested with latest stable and eosjs@prerelease (6.1.1)
eos.getBlock()
returns information for a specific block.
eos.getTransaction()
returns information for a specific transaction.
eos.getTransactions()
returns information for transactions from a specific account.
Can I get a list of the latest blocks and transactions using eosjs?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.