https://hivexplorer.com/tx/bffd8beb48e5e00f2ad26217916e774f21256bd0
这几天趁着低价power up了些,重构了喵星时又复习了下hivejs的各项功能,上午时又试了下Hive claim account,想不到,竟然还能用哦!
Hive claim account是个相对古老和冷门的功能,它是新用户注册的一个提前权限,拿到它之后就可以免费注册新用户。这听起来有点绕口,理解起来也有些难度,要怪的话就怪当初设计它的大聪明吧,很多概念确实蛮费解的。
HP超过1万的可以试试(消耗RC,每天大约可以领两个),以下是代码:
npm install @hiveio/dhive //安装包
import dhive from "@hiveio/dhive"
import { Client } from "@hiveio/dhive"
const client = new Client(["https://api.openhive.network", "https://api.hive.blog", "https://rpc.mahdiyari.info" ])
let i = 0
//自动获取claim_account
let claimaccount = function() {
i++
console.log(1111,i)
const creator = "lemooljiang"
const active_key = "5Kovxxxxxxxxxx" //使用资金密钥
return new Promise(resolve => {
const wif = dhive.PrivateKey.fromString(active_key)
const fee = dhive.Asset.from(0, 'HIVE')
const op = [
'claim_account',
{
creator: creator,
extensions: [],
fee: fee
}]
client.broadcast.sendOperations([op], wif).then(function (result) {
console.log('11,Included in block: ' + result.block_num)
console.log('222,申明新帐户创建成功!' )
resolve("ok")
}, function (error) {
console.error(error)
console.log('333,申明新帐户创建失败!' )
resolve("err")
})
})
}
claimaccount()
//setInterval(claimaccount, 5000) //每5秒申领一次,多次
不明觉厉,哈哈👍👍