Is it possible to create an account in mainnet using RPC calls?
First, I built EOSIO nodeos in my own remote server, and I successfully created my coworker's account using cleos.
$ cleos system newaccount <MY ACCOUNT> <COWORKER's ACCOUNT> <owner-publickey><active-publickey> --stake-net "0.1 EOS" --stake-cpu "0.1 EOS" --buy-ram-kbytes 4
Now, I went on to create an account using RPC call for my web service.
However, there is not system api available from developers.eos.io/eosio-nodeos/reference.
I went on to search a bit deeper.
As I felt a bit frustrated, I decided to test this eosjs library to make a new account using one of the Block Producer's public API endpoints, and it worked!
The source code is like this.
// Configure BP httpEndpoint and chainId
const config = {
chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
keyProvider: ['MY PRIVATE KEY'],
httpEndpoint: 'https://api.eosnewyork.io:443',
verbose: false, // API activity
broadcast: true,
sign: true,
expireInSeconds: 60
}
// Create a client
const eos = Eos(config)
// Make a transaction to create a new account
eos.transaction(tr => {
tr.newaccount({
creator: 'myaccount',
name: 'coworker's account',
owner: pubkey,
active: pubkey
})
tr.buyrambytes({
payer: 'myaccount',
receiver: 'coworker's account',
bytes: 8192
})
tr.delegatebw({
from: 'myaccount',
receiver: 'coworker's account',
stake_net_quantity: '0.1000 EOS',
stake_cpu_quantity: '0.1000 EOS',
transfer: 0
})
})
I wonder how could this be possible? I believe eosjs library uses https APIs, right? Is there something I am missing?
Thanks in advance.