Created
February 19, 2018 23:20
-
-
Save mcfarhat/e23f729309b34a7b3e7409b4baa0eef9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<!-- including steemjs library for performing calls --> | |
<script src="https://cdn.steemjs.com/lib/latest/steem.min.js"></script> | |
<script> | |
create_steemit_user(); | |
function create_steemit_user(){ | |
//set the proper steemit node to be used, otherwise default steem-js node will fail | |
steem.api.setOptions({ url: 'https://api.steemit.com' }); | |
//variable containing the new password . Suggest to use http://passwordsgenerator.net/ and set a min size of 50 chars, and DO NOT INCLUDE symbols as those are invalid | |
var wif = ""; | |
//WIF of the user creating the account | |
var owner_wif = ""; | |
//name of user creating the account | |
var owner_account = ""; | |
//new user account name | |
var new_account = ""; | |
//the fee to be used when creating the account. Make sure the value is set according to this template. I haven't used a lower value and eventually the amount will be sent over to the receiving new account | |
var fee = "0.200 STEEM"; | |
//set the amount of SP to delegate to this account. This is the min value being 15 STEEM for an account to be properly functional | |
var delegation = "30663.815330 VESTS"; | |
//meta data and extensions can be left blank for now | |
var jsonMetadata = ""; | |
var extensions = ""; | |
/********************** process ****************************/ | |
console.log('attempting creation of account:'+new_account); | |
//make sure account name is valid | |
var account_invalid = steem.utils.validateAccountName(new_account); | |
if (account_invalid == null){ | |
//make sure account does not already exist | |
steem.api.getAccounts([new_account], function(err, result) { | |
console.log(err, result); | |
//no matches found | |
if (result.length==0){ | |
/* if the code doesn't work, you might need to uncomment this, and change the wif at the top to password */ | |
//var wif = steem.auth.toWif(new_account, pass, 'owner'); | |
//generate the keys based on the account name and password | |
var publicKeys = steem.auth.generateKeys(new_account, wif, ['owner', 'active', 'posting', 'memo']); | |
var owner = { weight_threshold: 1, account_auths: [], key_auths: [[publicKeys.owner, 1]] }; | |
var active = { weight_threshold: 1, account_auths: [], key_auths: [[publicKeys.active, 1]] }; | |
var posting = { weight_threshold: 1, account_auths: [], key_auths: [[publicKeys.posting, 1]] }; | |
//console.log(posting); | |
steem.broadcast.accountCreateWithDelegation(owner_wif, fee, delegation, owner_account, new_account, owner, active, posting, publicKeys.memo, jsonMetadata, extensions, function(err, result) { | |
console.log(err, result); | |
}); | |
/*steem.broadcast.accountCreate(owner_wif, fee, owner_account, new_account, owner, active, posting, publicKeys.memo, jsonMetadata, function(err, result) { | |
console.log(err, result); | |
});*/ | |
}else{ | |
console.log('account already exists'); | |
} | |
}); | |
}else{ | |
console.log(account_invalid); | |
} | |
} | |
</script> | |
</head> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment