前端实现SP代理的终级解决方案
因为涉及到要做SP代理的一个功能,找起文档来真是要命,翻了半天也没有一个文档说明白的。看看官方的文档:
Delegates STEEM POWER, denominated in VESTS, from a delegator to the delegatee. Requires the delegator's private WIF key. Set the delegation to 0 to undelegate.
steem.broadcast.delegateVestingShares(wif, delegator, delegatee, vesting_shares, function(err, result) {
console.log(err, result);
});
wif - the active wif key, used to send a delegation, use the market, send transfers and more...
delegator - the account that sent the delegation
delegatee - the account that gets the delegation
vesting_shares - the number of vests you send, steem to vests calculator Here
看这说明要是能整明白那就是天才了!这估计只是开发员的备忘录了,啥也没说明。以前倒是零星看到些技术文档,那时没留意,现在也找不到了。问了下鱼老板,给了些建议和文档,又是一波折腾,总算是搞定的。
前端实现SP代理主要有三步:
- SP要先换算成VESTS。
- VESTS整成合规的格式,主要是6位小数加字符串。
- 执行代理函数
delegateVestingShares。
这三步也算是实现SP代理的终极方案了,不用再去查文档了!
第一步. SP要先换算成VESTS。
let s = await that.steem.api.getDynamicGlobalPropertiesAsync()
let sp_to_vests = parseFloat(s.total_vesting_shares) / parseFloat(s.total_vesting_fund_steem))
//从系统的参数中找到两个值,从面计算出换算比例,当前 1 SP = 1935.2059 VESTS
第二步. VESTS整成合规的格式
let b = '1.8' * sp_to_vests //1.8个SP
let c = b.toFixed(6)
let vests = c+' VESTS'
第三步执行代理函数
async delegate(){
let wif = '5Kxxxxxx'
let delegator = 'timool'
let delegatee = "Tsteem"
let a = await this.steem.api.getDynamicGlobalPropertiesAsync()
let sp_to_vests = parseFloat(a.total_vesting_shares) / parseFloat(a.total_vesting_fund_steem)
let b = '1.8' * sp_to_vests
let c = b.toFixed(6)
let vests = c+' VESTS'
await this.steem.broadcast.delegateVestingSharesAsync(wif, delegator, delegatee, vests)
}
按以上三步来基本就没问题了,想怎么整都可以了。不过要注意最小代理量不能小于1SP,要取消代理直接把代理量设为0即可,取消代理要有7天才能回到原有帐户。
Leave 前端实现SP代理的终级解决方案 to:
Read more #cn posts
Best Posts From lemooljiang
We have not curated any of lemooljiang's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From lemooljiang
- DeepTutor:AI个性化辅导平台 / ai #57
- ComfyUI:可编程和自动化的PS / ai #56
- 将Neo4j封装进Agent / ai #55
- 闲鱼省钱大法:极限0.5折!
- 对Neo4j批量导入结构化数据 / ai #54
- langchain对neo4j进行交互,写入和查询数据 / ai #53
- 知识图谱和图数据库Neo4j的作用和使用场景 / ai #52
- SpaceX、美股和比特币
- 又是币圈血洗日!
- 链股合流,当币安也开始卖股票啰
- 天涯社区重启,爷青回?
- 诺基亚在AI时代重新杀回来啦
- 《2049:未来10000天的可能》书中的镜像世界为什么不叫元宇宙
- 今天适合吃披萨
- 开通即被封,别再给Claude送人头了!
- 两根内存条引发的“官司”
- AI·Joe V12更新, 更新GPT-5.5和DeepSeek V4 等
- 中医进校园活动反响热烈
- 猪价低伤农,猪价贵伤民
- Solidity开发指南