命令如下
cleos -u https://nodes.get-scatter.com:443 get table eosio eosio rammarket
获取的结果为
{
"rows": [{
"supply": "10000000000.0000 RAMCORE",
"base": {
"balance": "12341975994 RAM",
"weight": "0.50000000000000000"
},
"quote": {
"balance": "5568015.6361 EOS",
"weight": "0.50000000000000000"
}
}
],
"more": false
}
然后使用Bancor算法,计算出需要nKB的RAM的价格
RAM价格 = (n * quote.balance) / (n + base.balance / 1024)
RPC代码实现如下
const wif = '5JC9FdRjX3c3fsB62S5Tz22LgTuRHegb1XEV16uft8u3njmm9E5'
eos = Eos({
httpEndpoint: 'https://nodes.get-scatter.com:443',
chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
keyProvider: wif,
verbose: true
})
eos.getTableRows(true,"eosio", "eosio", "rammarket").then(result => {
console.log(1 * result.rows[0].quote.balance.split(" ")[0] / (1 + result.rows[0].base.balance.split(" ")[0] / 1024));
}).catch(e => {
console.error(e);
})
当前返回价格:0.4716754832469308 EOS/Kib
参考:github
版权属于:区块链中文技术社区 / 转载原创者
本文链接:https://bcskill.com/index.php/archives/255.html
相关技术文章仅限于相关区块链底层技术研究,禁止用于非法用途,后果自负!本站严格遵守一切相关法律政策!