기존
STEEMIT_CREATE_ACCOUNT_WITH_STEEM_MODIFIER
변경 후
STEEM_CREATE_ACCOUNT_WITH_STEEM_MODIFIER
위 처럼 API 약간의 변경이 적용 된 것 같습니다.
전반적으로 PREFIX가 STEEMIT_ => STEEM_ 로 변경된 것 같습니다.
(언제부터 바뀐지는 모르겠음...)
/*
계정 생성 프로그램
참조 :
https://github.com/steemit/steem-js
https://nhj7.github.io/steem.apps/#AccountCreator
https://steemit.com/programming/@armandocat/how-to-create-a-new-steem-account-by-using-another-account-as-the-creator-javascript
*/
const steem = require('steem');
const roles = ["POSTING", "ACTIVE", "OWNER", "MEMO"];
// 내 계정명과 ACTIVE_KEY 또는 OWNER PRIVE KEY
const OWNER_ACC_NAME = "내 계정 명";
const OWNER_ACTIVE_KEY = "내 계정 엑티브 키";
// 만들려고 하는 계정 명
const CREATE_ACC_NAME = "만들려고 하는 계정 명";
// 통신 설정
steem.api.setOptions({ url: 'https://api.steemit.com' });
// 랜덤 암호 생성 및 공개키, 개인키를 생성한다.
const newAccountPassword = steem.formatter.createSuggestedPassword();
const arrPublicKey = steem.auth.generateKeys(OWNER_ACC_NAME, newAccountPassword, roles);
const arrPrivateKey = steem.auth.getPrivateKeys(OWNER_ACC_NAME, newAccountPassword, roles);
const owner = {
weight_threshold: 1,
account_auths: [],
key_auths: [
[arrPublicKey["OWNER"], 1]
]
};
const active = {
weight_threshold: 1,
account_auths: [],
key_auths: [
[arrPublicKey["ACTIVE"], 1]
]
};
const posting = {
weight_threshold: 1,
account_auths: [],
key_auths: [
[arrPublicKey["POSTING"], 1]
]
};
// 출처 : https://steemit.com/programming/@armandocat/how-to-create-a-new-steem-account-by-using-another-account-as-the-creator-javascript
// https://github.com/nhj1002/steem-utility/blob/master/create_account.html
// 계정 생성 비용을 출력
function getFee(config, chainProps) {
// STEEMIT_CREATE_ACCOUNT_WITH_STEEM_MODIFIER => STEEM_CREATE_ACCOUNT_WITH_STEEM_MODIFIER
var ratio = config['STEEM_CREATE_ACCOUNT_WITH_STEEM_MODIFIER'];
var fee = Number(chainProps.account_creation_fee.split(" ")[0]); // 0.100 STEEM
// console.log( config );
// dsteem 쓸 필요 없이 자리수 소숫점 아래 3자리를 잘 맞춰주면 됨.
return (ratio * fee).toFixed(3) + " STEEM";
}
// 계정 생성 여부 확인
steem.api.getAccounts( [ CREATE_ACC_NAME ] , function(err, result) {
// 계정이 생성되지 않은 경우
if( result[0] == null ){
// 계정을 생성한다
createAccount();
// createAccountTEST();
}else{
console.log( CREATE_ACC_NAME + " 는 존재하는 계정명 입니다.");
}
});
// 계정을 생성한다
function createAccount(){
// 설정 정보를 읽어들인다.
steem.api.getConfig(function(err, config) {
// 오류 발생 시 중지
if (err)
throw new Error(err);
// 체인 설정 정보를 읽어들인다
steem.api.getChainProperties(function(err2, chainProps) {
// 계정 생성의 비용 배수값
const ratio = config['STEEM_CREATE_ACCOUNT_WITH_STEEM_MODIFIER'];
console.log("[ 생성비용 ]");
console.log(getFee(config, chainProps));
console.log();
console.log("[ 계정명 ]");
console.log( CREATE_ACC_NAME );
console.log();
console.log("[ 암호 ]");
console.log( newAccountPassword );
console.log();
console.log("[ 공개키 ]");
console.log( arrPublicKey );
console.log();
console.log("[ 개인키 ]");
console.log( arrPrivateKey );
console.log();
steem.broadcast.accountCreate(OWNER_ACTIVE_KEY, getFee(config, chainProps), OWNER_ACC_NAME,
CREATE_ACC_NAME, owner, active, posting, arrPublicKey.MEMO,
'', (err, result) => {
// 정보 출력
console.log(err, result);
});
});
});
}
test