Here is how you can easily create a Steemit account programmatically

in steemit •  2 months ago  (edited)


(@elliot.alderson account creation from my script - transaction e343385a)


This simple tutorial will allow you to create a Steemit account in seconds, simply pasting a script in any browser (I strongly recommend using Brave browser for its security and speed!).

NOTES:

  • This script requires a pre-existing Steemit account's active key to work.

It is completely safe though! If you have a basic understanding of Javascript you can verify yourself that your keys are not sent or stored anywhere!

  • You need to have at least 3 STEEM in your account balance that will be burned by Steemit to create your account.

STEP 1


Open your favorite browser on any site (I strongly recommend using Brave browser)
and open the DevTools (Ctrl + Shift + J on Linux/Windows and Cmd + Opt + J on Mac)

STEP 2


Open 2 tabs:
https://cdn.jsdelivr.net/npm/steem/dist/steem.min.js (SteemJs)
https://unpkg.com/dsteem@0.8.7/dist/dsteem.js (Dsteem.js)
and copy and paste (Ctrl + A and Ctrl + C) the content of both pages into the Browser Console (DevTools) that you opened in the first tab.

STEP 3


Copy and paste my script below in the Console:

const opts = { addressPrefix: 'STM' };
const client = new dsteem.Client('https://api.steemit.com');


const checkAccount = async (username) => {
  const accountInvalid = steem.utils.validateAccountName(username);
  if (accountInvalid) throw new Error(accountInvalid);

  let isAvailable = false;
  const _account = await client.database.call('get_accounts', [[username]]);
  if (_account.length === 0) {
    isAvailable = true;
  }
  return isAvailable;
};

const createAccount = async (config) => {
  const {
    newUsername: username, password, creator, privateKeyStr,
  } = config;

  const available = await checkAccount(username);
  if (!available) throw new Error(`\n${username} already taken.\n`);

  const ownerKey = dsteem.PrivateKey.fromLogin(username, password, 'owner');
  const ownerAuth = {
    weight_threshold: 1,
    account_auths: [],
    key_auths: [[ownerKey.createPublic(opts.addressPrefix), 1]],
  };
  const activeKey = dsteem.PrivateKey.fromLogin(username, password, 'active');
  const activeAuth = {
    weight_threshold: 1,
    account_auths: [],
    key_auths: [[activeKey.createPublic(opts.addressPrefix), 1]],
  };
  const postingKey = dsteem.PrivateKey.fromLogin(username, password, 'posting');
  const postingAuth = {
    weight_threshold: 1,
    account_auths: [],
    key_auths: [[postingKey.createPublic(opts.addressPrefix), 1]],
  };
  const memoKey = dsteem.PrivateKey.fromLogin(username, password, 'memo').createPublic(opts.addressPrefix);

  // Non-discounted account creation - in alternative you can burn RC if you have tons
  const op = [
    'account_create',
    {
      fee: '3.000 STEEM',
      creator,
      new_account_name: username,
      // keys
      owner: ownerAuth,
      active: activeAuth,
      posting: postingAuth,
      memo_key: memoKey,
      // meta
      json_metadata: '',
    },
  ];

  console.log(`Creating account ${username}. New Owner key: ${ownerKey} <<<<<<<<<<< SAVE !!!`);
  const privateActiveKey = dsteem.PrivateKey.from(privateKeyStr);
  client.broadcast.sendOperations([op], privateActiveKey).then(
    (result) => console.log('All good.', JSON.stringify(result)),
    console.error,
  );
};


const config = {
  newUsername: 'elliot.alderson',
  password: 'password', // eg. a 32 chars long password like 3l4kj3kj4l5h34jh5gjhg34v52hg34fr
  creator: 'marcocasario',
  privateKeyStr: '5J11111111111111111111111111111111111111111111111Fr', // private active key
};
createAccount(config);

STEP 4

Change the config at the bottom of the script with the values that you want to use.

let config = {
  newUsername: 'elliot.alderson', // ==> the new account that you want to create
  password: 'password', // ==> a long random password like 3l4kj3kj4l5h34jh5gjhg34v52hg34fr
  creator: 'marcocasario', // ==> the name of your account with at least 3 STEEM
  privateKeyStr: '5J11111111111111111111111111111111111111111111111Fr', // ==> The private active key of your account
};

STEP 6

Press enter and read the result.

STEP 7

Save the private key printed in the log if the account creation was successful!! If you don't save that key you just wasted 3 STEEM !! :(



The code in this tutorial checks that the username you chose is valid, it verifies that it does not exist already and if these two preconditions are verified it creates it with 0 SP. If you also want to add a delegation programmatically see my previous post.


If after the first execution you want to create a new user, simply change the config passed to the entry point function like this:

createAccount(
{
  newUsername: 'newuser123',
  password: 'password',
  creator: 'youraccount',
  privateKeyStr: '5J11111111111111111111111111111111111111111111111Fr', // private active key
}
);

... and press enter again.

Enjoy!! =]


Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Andando su steemworld.org si può creare un nuovo account con 3 steem, o gratis con 10,717,235,944,000 RC

Esatto, utilizza le stesse API.

Se ti interessa posso postare anche uno script per creare un account da codice e bruciando RC invece di pagare 3 steem.

Penso che interessi a meno però visto che richiede una marea di RC.

!shop
$trdo
!BEER
for you

Congratulations @eii, you successfuly trended the post shared by @gaottantacinque!
@gaottantacinque will receive 0.04176563 TRDO & @eii will get 0.02784375 TRDO curation in 3 Days from Post Created Date!

"Call TRDO, Your Comment Worth Something!"

To view or trade TRDO go to steem-engine.com
Join TRDO Discord Channel or Join TRDO Web Site


Hey @gaottantacinque, here is a little bit of BEER from @eii for you. Enjoy it!

Learn how to earn FREE BEER each day by staking.

Congratulations @gaottantacinque, your post successfully recieved 0.04176563 TRDO from below listed TRENDO callers:

@eii earned : 0.02784375 TRDO curation


To view or trade TRDO go to steem-engine.com
Join TRDO Discord Channel or Join TRDO Web Site