这里, 我们要借助 Steem 官方提供的 steem-js SDK, 来创建账号, 主要用到的 API 有两个:
steem.auth.generateKeys 用于生成4组密钥(owner, active, posting, memo),
steem.broadcast.accountCreate 用于创建账号
register() {
let newAccountName = "bettyliu" //新帐户
let newAccountPassword = "FDDjjjRTLOu456" //新帐户密码
let publicKeys = this.steem.auth.generateKeys(newAccountName, newAccountPassword, ['owner', 'active', 'posting', 'memo'])
let owner = { weight_threshold: 1, account_auths: [], key_auths: [[publicKeys.owner, 1]] }
let active = { weight_threshold: 1, account_auths: [], key_auths: [[publicKeys.active, 1]] }
let posting = { weight_threshold: 1, account_auths: [], key_auths: [[publicKeys.posting, 1]] }
let memoKey = publicKeys.memo
console.log(1234, publicKeys)
console.log(23456, active)
let creator = "lemooljiang" //创建者
let creatorWif = "5Jbfffffffffffffff" //创建者的资金密钥
let fee = "3.000 STEEM" //费用
let jsonMetadata = ""
this.steem.broadcast.accountCreate(
creatorWif,
fee,
creator,
newAccountName,
owner,
active,
posting,
memoKey,
jsonMetadata,
(err, result) => {
if(err){
console.log(444, '创建失败!', err)
}else{
console.log(666, '创建成功!', result)
}
})
}
RE: SteemJS中文手册