2

I am creating accounnt using EOSjs(20.0.0-beta1).My account_creat function goes like this:

const createNewAccount = async (
  account_name,
  owner_publicKey,
  active_publicKey
) => {
  try {
    const result = await api.transact (
      {
        actions: [
          {
            account: 'eosio',
            name: 'newaccount',
            authorization: [
              {
                actor: 'nirdxxxxxxxx',
                permission: 'active',
              },
            ],
            data: {
              creator: 'nirdxxxxxxxx',
              name: account_name,
              owner: {
                threshold: 1,
                keys: [
                  {
                    key: owner_publicKey,
                    weight: 1,
                  },
                ],
                accounts: [],
                waits: [],
              },
              active: {
                threshold: 1,
                keys: [
                  {
                    key: active_publicKey,
                    weight: 1,
                  },
                ],
                accounts: [],
                waits: [],
              },
            },
          },
          {
            account: 'eosio',
            name: 'buyrambytes',
            authorization: [
              {
                actor: 'nirdxxxxxxxx',
                permission: 'active',
              },
            ],
            data: {
              payer: 'nirdxxxxxxxx',
              receiver: account_name,
              bytes: 8192,
            },
          },
          {
            account: 'eosio',
            name: 'delegatebw',
            authorization: [
              {
                actor: 'nirdxxxxxxxx',
                permission: 'active',
              },
            ],
            data: {
              from: 'nirdxxxxxxxx',
              receiver: account_name,
              stake_net_quantity: '1.0000 EOS',
              stake_cpu_quantity: '1.0000 EOS',
              transfer: false,
            },
          },
        ],
      },
      {
        blocksBehind: 3,
        expireSeconds: 30,
      }
    );
    console.log ('transaction_id is : ', result.transaction_id);
    return trans_id;
  } catch (err) {
    console.log ('error is : ___', err);
  }
};

when I execute the code it gives error:

missing newaccount.newact (type=name)
    at Object.serializeStruct [as serialize] (/home/nirdesh.kumar/node_modules/eosjs/dist/eosjs-serialize.js:566:27)

Is this error due to version(20.0.0-beta)? Did jungle net changed something because this code working 2 days ago?

2 Answers 2

1

This error is caused by recent updates to the EOSIO system contract, and is not a bug caused by the new eosjs v20 beta. In versions 1.4.0 & 1.5.0, the name field within eosio::newaccount has been changed to newact. And, then, in their respective follow-up version 1.4.1 & 1.5.1, the field was reverted back to name.

You can fix this bug by changing the transaction newaccount actions, as follows...

        account: 'eosio',
        name: 'newaccount',
        authorization: [
          {
            actor: 'nirdxxxxxxxx',
            permission: 'active',
          },
        ],
        data: {
          creator: 'nirdxxxxxxxx',
          newact: account_name, // <--- Field key changed from 'name'
1
  • Currently, both the Jungle testnet, and the Cryptokylin testnet are running eosio v1.5.0, which causes this "bug". In the near future, once each testnet has updated the eosio version to 1.x.1, this issue may no longer exist. Commented Dec 6, 2018 at 22:53
1

I have Installed eosjs(16.0.x) and also I use promises apply some other changes, If someone goes through this problem, you can see

I defined my config file like :

let config = {
  chainId: '038f4b0fc8ff18a4f0842a8f0564611f6e96e8535901dd45e43ac8691a1c4dca', // 32 byte (64 char) hex string
  keyProvider: [creator_account_active_key], // WIF string or array of keys..
  httpEndpoint: 'http://dev.cryptolions.io:38888',
  expireInSeconds: 60,
  broadcast: true,
  verbose: false, // API activity
  sign: true,
};

As I am using jungeltest net to test my code, I provide the endpoint of test net. Now it's time for account creation function:

const eos = Eos (config);

function createaccount (name_of_new_account, owner_publicKey, active_publicKey) {
  return new Promise (async function (resolve, reject) {
    eos
      .transaction (tr => {
        tr.newaccount ({
          creator: EOS_acount_of_creator,
          name: name_of_new_account,
          owner: owner_publicKey,
          active: active_publicKey,
        });
        tr.buyrambytes ({
          payer: EOS_acount_of_creator,
          receiver: name_of_new_account,
          bytes: 3000,
        });
        tr.delegatebw ({
          from: EOS_acount_of_creator,
          receiver: name_of_new_account,
          stake_net_quantity: '0.0500 EOS',
          stake_cpu_quantity: '0.1500 EOS',
          transfer: 0,
        });
      })
      .then (data => {
        resolve (data.transaction_id);
      })
      .catch (error => {
        reject (error);
      });

  });
}

Remember your account should be 12 characters long,if you pass a valid name and keys this function return transaction_id. You can use this transaction_id to see your transaction on jungle test net.

1
  • This answer does not address the problem. While using an "old" version of eosjs, might solve the issue for now, we should really be solving the problem using the latest versions. And, although the latest version (v20) of eosjs is still in beta, this issue can easily be remedied. Commented Dec 6, 2018 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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