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
//VESTS和SP换算关系
let that = this
async function main() {
let s = await that.steem.api.getDynamicGlobalPropertiesAsync()
console.log(11, s)
console.log(12, s.total_vesting_shares)
console.log(13, s.total_vesting_fund_steem)
console.log(14, "sp_to_vests", parseFloat(s.total_vesting_shares) / parseFloat(s.total_vesting_fund_steem))
}
main()
//////
12 "225776929016.290304 VESTS"
13 "116668118.933 STEEM"
当前 1 SP = 1935.2059 VESTS
steem.api.getVestingDelegations('ned', '', 2, function(err, result) {
console.log(err, result);
});
async delegate(){
let wif = '5KNxxxxxxxxxxxxxxx' // active key
let delegator = 'timool'
let delegatee = tsteem.test
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)
}
////执行结果:
operations: Array(1)
0: Array(2)
0: "delegate_vesting_shares"
1:
delegatee: "tsteem.test"
delegator: "timool"
vesting_shares: "3483.359523 VESTS"
__proto__: Object
length: 2
注意: 最小代理量不能小于1SP,要取消代理直接把代理量设为0即可,取消代理要有7天才能回到原有帐户。
RE: SteemJS中文手册