I am trying to create and account from another account, both on JungleNet. I am using junglenet 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 = 'REDACTED';
const privateKeys = [privateKey1];
const publicKey = PrivateKey.fromString(privateKey1).toPublic().toString();
const signatureProvider = new JsSignatureProvider(['REDACTED']);
const rpc = new JsonRpc('http://jungle2.cryptolions.io:80', {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: '65990145',
ref_block_prefix: '2469844007',
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,
keys: [{
key: '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:20637) UnhandledPromiseRejectionWarning: Error: Number is out of range
at checkRange (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-serialize.js:690:15)
at Object.serialize (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-serialize.js:719:68)
at Object.serializeStruct [as serialize] (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-serialize.js:564:28)
at Object.serializeStruct [as serialize] (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-serialize.js:555:19)
at Api.serialize (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-api.js:245:41)
at Api.serializeTransaction (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-api.js:254:14)
at Api.<anonymous> (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-api.js:380:54)
at step (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-api.js:47:23)
at Object.next (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-api.js:28:53)
at fulfilled (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-api.js:19:58)
(node:20637) 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:20637) [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?