I am trying to create and account from another account, both on JungleNet. I am using dffuse for my rpc. Here is my code:
const {Api, JsonRpc} = require('eosjs');
const {JsSignatureProvider} = require('eosjs/dist/eosjs-jssig');
const fetch = require('node-fetch');
const {TextDecoder, TextEncoder} = require('util');
const { PrivateKey } = require('eosjs-ecc');
const privateKey1 = '5Kh3sXKTY3ed4htCD5af69MiALyk44w3PdX18smX5hDV9Kx3AAh';
const privateKeys = [privateKey1];
const publicKey = PrivateKey.fromString(privateKey1).toPublic().toString();
const signatureProvider = new JsSignatureProvider(['5Kh3sXKTY3ed4htCD5af69MiALyk44w3PdX18smX5hDV9Kx3AAh']);
const rpc = new JsonRpc('https://jungle.eos.dfuse.io/', {fetch});
const api = new Api({rpc, signatureProvider, textDecoder: new TextDecoder(), textEncoder: new TextEncoder()});
(async () => {
const res = await api.transact({
expiration: new Date(new Date().getTime() + 30 * 60000),
ref_block_num: 65981473,
ref_block_prefix: 4183230361,
actions: [{
account: 'eosio',
name: 'newaccount',
authorization: [{
actor: 'winterwind12',
permission: 'active',
}],
data: {
creator: 'winterwind12',
name: 'winterwind14',
owner:{
threshold: 1,
keys: [{
key: 'EOS5ZWJYNoFUYN62iQRc77LEdY2GfmRxLUgsbtWwMstJWbJwGMPHs',
weight: 1
}],
accounts: [],
waits: []
},
active: {
threshold: 1,
key: [{
keys: 'EOS5ZWJYNoFUYN62iQRc77LEdY2GfmRxLUgsbtWwMstJWbJwGMPHs',
weight: 1
}],
accounts: [],
waits: []
},
},
},
{
account: 'eosio',
name: 'buyrambytes',
authorization: [{
actor: 'winterwind12',
permission: 'active',
}],
data: {
payer: 'winterwind12',
receiver: 'winterwind14',
bytes: 8192
},
},
{
account: 'eosio',
name: 'delegatebw',
authorization: [{
actor: 'winterwind12',
permission: 'active',
}],
data: {
from: 'winterwind12',
receiver: 'winterwind14',
stake_net_quantity: '0.5000 SYS',
stake_cpu_quantity: '0.5000 SYS',
transfer: false,
}
}]
})
// {broadcast: false, sign: true})
// {blocksBehind: 3, expireSeconds: 30})
console.log(res);
})();
After executing this, I get an error like this:
(node:18425) UnhandledPromiseRejectionWarning: Error: fetching abi for eosio: unknown key (eosio::chain::name):
at new RpcError (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-rpcerror.js:26:28)
at JsonRpc.<anonymous> (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-jsonrpc.js:118:35)
at step (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-jsonrpc.js:36:23)
at Object.next (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-jsonrpc.js:17:53)
at fulfilled (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-jsonrpc.js:8:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:18425) 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:18425) [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.
Where am I going wrong with my code?