0

I have created a MultiNode Setup using the Bios Boot sequence https://developers.eos.io/welcome/latest/tutorials/bios-boot-sequence. And created the accounts as 'eosio' & 'accountnum11'. I am trying create accounts using the 'eosjs' package as follows.

           const { Api,JsonRpc,RpcError } = require('eosjs');
           const { JsSignatureProvider} = require('eosjs/dist/eosjs-jssig');
           const fetch = require('node-fetch'); // node only; 
           const { TextEncoder,TextDecoder} = require('util');
           const defaultPrivateKey = config.PRIVATE_KEY;

           const signatureProvider = new JsSignatureProvider([defaultPrivateKey]);

           const api = new Api({
                             rpc,
                             signatureProvider,
                             textDecoder: new TextDecoder(),
                             textEncoder: new TextEncoder()
           })


            try {


                const result = 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: 'eosio',
                                                 permission: 'active',
                                          }],
                                          data: {
                                                creator: 'eosio',
                                                name: 'test',
                                                owner:{
                                                    threshold: 1,
                                                    keys: [{
                                                       key: myPublic.toString(),
                                                       weight: 1
                                                    }],
                                                    accounts: [],
                                                    waits: []
                                                },
                                                active: {
                                                   threshold: 1,
                                                   key: [{
                                                         keys:myPublic.toString(),
                                                         weight: 1
                                                        }],
                                                   accounts: [],
                                                   waits: []
                                                },
                                            },
                                         },
                                         {
                                             account: 'eosio',
                                             name: 'buyrambytes',
                                             authorization: [{
                                                     actor: 'eosio',
                                                     permission: 'active',
                                             }],
                                             data: {
                                                   payer: 'eosio',
                                                   receiver: 'test',
                                                   bytes: 8192
                                                 },
                                            },
                                            {
                                                account: 'eosio',
                                               name: 'delegatebw',
                                                           authorization: [{
                                                           actor: 'eosio',
                                                           permission: 'active',
                                                       }],
                                             data: {
                                                  from: 'eosio',
                                                  receiver: 'test',
                                                  stake_net_quantity: '0.5000 SYS',
                                                  stake_cpu_quantity: '0.5000 SYS',
                                                 transfer: false,
                                            }
                                          }]
                              })

The above operation returns the following error.

             Error: missing authority.keys (type=key_weight[])
at Object.serializeStruct [as serialize] (/home/crissi/Documents/EOSS/EOS-APPLICATION/node_modules/eosjs/dist/eosjs-serialize.js:597:27)
at Object.serializeStruct [as serialize] (/home/crissi/Documents/EOSS/EOS-APPLICATION/node_modules/eosjs/dist/eosjs-serialize.js:590:28)
at Object.exports.serializeActionData (/home/crissi/Documents/EOSS/EOS-APPLICATION/node_modules/eosjs/dist/eosjs-serialize.js:1069:12)
at Object.exports.serializeAction (/home/crissi/Documents/EOSS/EOS-APPLICATION/node_modules/eosjs/dist/eosjs-serialize.js:1078:23)
at Api.<anonymous> (/home/crissi/Documents/EOSS/EOS-APPLICATION/node_modules/eosjs/dist/eosjs-api.js:311:71)
at step (/home/crissi/Documents/EOSS/EOS-APPLICATION/node_modules/eosjs/dist/eosjs-api.js:49:23)
at Object.next (/home/crissi/Documents/EOSS/EOS-APPLICATION/node_modules/eosjs/dist/eosjs-api.js:30:53)
at fulfilled (/home/crissi/Documents/EOSS/EOS-APPLICATION/node_modules/eosjs/dist/eosjs-api.js:21:58)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:182:7)

Any workarounds for the error??

0

It looks like you don't define myPublic anywhere, and therefore the keys field is empty, causing the error. You can get the public key from your private key using the function getPublicKey here: https://github.com/EOSIO/eosjs/blob/1cf9bf53d21d3f461f61970d3295ee1fc2ba56d1/src/PrivateKey.ts#L55

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.