0

eosjs 20.0.0

cannot create new account using the eosjs rpc call see following code snippet below.

const addPrivateKey = "EOS8i1CXTY4Sz39XaQWX2RpccsCZ1nWM3w9zRhjCFChdci2Y65ck4";
const rpc = new eosjs_jsonrpc.JsonRpc('http:///[ip address]:8888');
const signatureProvider = new eosjs_jssig.JsSignatureProvider([addPrivateKey]);
const api = new eosjs_api.Api({ rpc, signatureProvider });

var returnmsg = "";
//alert("before async");

/(async () => {
try {
result = await rpc.get_info();
//const result = await rpc.get_account('alice');
//const result = await rpc.get_currency_balance('eosio.token', 'alice', 'SYS');
returnmsg += '\n\nTransaction pushed!\n\n' + JSON.stringify(result, null, 2);
console.log(returnmsg);
} catch (e) {
returnmsg = '\nCaught exception: ' + e;
if (e instanceof eosjs_jsonrpc.RpcError)
returnmsg += '\n\n' + JSON.stringify(e.json, null, 2);
console.log(returnmsg);
}
})();/

(async () => {
try {
const result = await api.transact({
actions: [{
account: 'eosio',
name: 'newaccount',
authorization: [{
actor: 'eosio',
permission: 'active',
}],
data: {
creator: 'eosio',
name: 'testnewaccount',
owner: {
threshold: 1,
keys: [{
key: 'EOS8i1CXTY4Sz39XaQWX2RpccsCZ1nWM3w9zRhjCFChdci2Y65ck4',
weight: 1
}],
accounts: [],
waits: []
},
active: {
threshold: 1,
keys: [{
key: 'EOS8i1CXTY4Sz39XaQWX2RpccsCZ1nWM3w9zRhjCFChdci2Y65ck4',
weight: 1
}],
accounts: [],
waits: []
},
},
}]
}, {
blocksBehind: 3,
expireSeconds: 30,
});
console.log(result);
} catch (e) {
returnmsg = '\nCaught exception: ' + e;
if (e instanceof eosjs_jsonrpc.RpcError)
returnmsg += '\n\n' + JSON.stringify(e.json, null, 2);
console.log(returnmsg);
}
}
)();

should be able to create an account using the following from web to /vi/chain/

OS/browser:

OS: [e.g. iOS]: Windows 10 Browser [e.g. chrome, safari]: Chrome Version [e.g. 22]: Version 73.0.3683.86 (Official Build) (64-bit)

Additional details below: [‎4/‎10/‎2019 8:40 PM] DelaCruz, Ericko:

No Title Angular CLI: 7.3.8 Node: 10.15.3 OS: win32 x64 Angular: 7.2.12 ... animations, common, compiler, compiler-cli, core, forms ... language-service, platform-browser, platform-browser-dynamic ... router

Package Version

@angular-devkit/architect 0.13.8
@angular-devkit/build-angular 0.13.8
@angular-devkit/build-optimizer 0.13.8
@angular-devkit/build-webpack 0.13.8
@angular-devkit/core 7.3.8
@angular-devkit/schematics 7.3.8
@angular/cli 7.3.8
@ngtools/webpack 7.3.8
@schematics/angular 7.3.8
@schematics/update 0.13.8
rxjs 6.3.3
typescript 3.2.4
webpack 4.29.0

Are we missing some parameters in the above json request?

  • A clear hint is that EOS8i... is the public key, however, it is called private key in the font. For security reasons, please don't post a real private key you use though! – Gassa Apr 11 at 0:10
  • Can you post the error message? Use the private key like suggested above. I ran into many issues throughout the betas for eosjs 20 so maybe something simple is tripping it. I know their docs were outdated at one point. – Nat Apr 18 at 18:59
2

In the first line you're entering an EOS public key in what should be a private key

const addPrivateKey = "EOS8i1CXTY4Sz39XaQWX2RpccsCZ1nWM3w9zRhjCFChdci2Y65ck4";

Change this to the private key but as the comments say, be sure you keep this private, don't upload it or anything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.