0

Is there a way to create an account via eos js

For example I would to avoid having to go to http://monitor.jungletestnet.io/#account to create an account on the testnet, is that possible?

1

Yes, it is possible. You can view the related EOS-JS documentation at the following link: https://github.com/EOSIO/eosjs/blob/e53c0e0bf791c22818ee3c9ea3592bcf1c0877ec/docs/2.-Transaction-Examples.md#create-new-account-multiple-actions


Create New Account (multiple actions)

const result = await api.transact({
  actions: [{
    account: 'eosio',
    name: 'newaccount',
    authorization: [{
      actor: 'useraaaaaaaa',
      permission: 'active',
    }],
    data: {
      creator: 'useraaaaaaaa',
      name: 'mynewaccount',
      owner: {
        threshold: 1,
        keys: [{
          key: 'PUB_R1_6FPFZqw5ahYrR9jD96yDbbDNTdKtNqRbze6oTDLntrsANgQKZu',
          weight: 1
        }],
        accounts: [],
        waits: []
      },
      active: {
        threshold: 1,
        keys: [{
          key: 'PUB_R1_6FPFZqw5ahYrR9jD96yDbbDNTdKtNqRbze6oTDLntrsANgQKZu',
          weight: 1
        }],
        accounts: [],
        waits: []
      },
    },
  },
  {
    account: 'eosio',
    name: 'buyrambytes',
    authorization: [{
      actor: 'useraaaaaaaa',
      permission: 'active',
    }],
    data: {
      payer: 'useraaaaaaaa',
      receiver: 'mynewaccount',
      bytes: 8192,
    },
  },
  {
    account: 'eosio',
    name: 'delegatebw',
    authorization: [{
      actor: 'useraaaaaaaa',
      permission: 'active',
    }],
    data: {
      from: 'useraaaaaaaa',
      receiver: 'mynewaccount',
      stake_net_quantity: '1.0000 SYS',
      stake_cpu_quantity: '1.0000 SYS',
      transfer: false,
    }
  }]
}, {
  blocksBehind: 3,
  expireSeconds: 30,
});
|improve this answer|||||
  • thanks a lot for pointing that out to me! I also was able to find it in the official docs now: eosio.github.io/eosjs/guides/2.-Transaction-Examples.html – standup75 Aug 23 '19 at 18:21
  • Yep, I made sure to link you the latest version you would find there. But for the future, in case those docs change or the link dies, I linked the github commit that showed the documentation at this time. Glad it helped out. – netuoso - EOS Titan Aug 23 '19 at 18:24

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.