Demo code about how to create a new account by Steem JS SDK
Here is the demo code which displays how to create a new account with Steem JS SDK in two different ways ( by taking fee or by taking interests of claimed account).
const steem = require('steem')
const creator = 'test1';
const activeWif = '';
const newUsername = 'test2';
const newPasswd = 'P5KZS6bp8sVxxxxxxxxxD48jwBKxshpNZxsYnJ';
const fee = '3.000 STEEM'
const newKeys = steem.auth.getPrivateKeys(newUsername, newPasswd, ['owner', 'active', 'posting', 'memo']);
console.log(newKeys);
const weightThreshold = 1;
const accountAuths = [];
const owner = {
weight_threshold: weightThreshold,
account_auths: accountAuths,
key_auths: [[newKeys.ownerPubkey, 1]],
};
const active = {
weight_threshold: weightThreshold,
account_auths: accountAuths,
key_auths: [[newKeys.activePubkey, 1]],
};
const posting = {
weight_threshold: weightThreshold,
account_auths: accountAuths,
key_auths: [[newKeys.postingPubkey, 1]],
};
const memoKey = newKeys.memoPubkey;
// create a new user by creator with 3.000 STEEM fee
steem.broadcast.accountCreate(activeWif, fee, creator, newUsername, owner, active, posting, memoKey, '{}', function(err, result) {
console.log(err, result);
});
// create a new user by creator with claimed account interests
const op = [
"create_claimed_account",
{
"creator": creator,
"new_account_name": newUsername,
"owner": owner,
"active": active,
"posting": posting,
"memo_key": memoKey,
"json_metadata": "{}"
}
];
const tx = {
operations: [op],
};
steem.broadcast.send(tx, [activeWif], function(err, result) {
console.log(err, result);
});
Thank you for reading. I'm a witness. You could find more on my site https://steem.fans
I would really appreciate your witness vote! You can vote by AuthSteem. Or open https://steemitwallet.com/~witnesses page, input ety001 to vote.
Thank you!
!thumbsup
Hello @ety001! You are the best!
command: !thumbsup is powered by witness @justyy and his contributions are: https://steemyy.com
More commands are coming!
Thank you very much.
Congratulations, you have enabled UVF by @boylikegirl
Common UVF commands:
1.uvf_info
Reply any post use "!uvf_info"
Display your UVF information