EOS 获取RAM实时价格
Posted 跨链技术践行者
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了EOS 获取RAM实时价格相关的知识,希望对你有一定的参考价值。
命令如下
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
以上是关于EOS 获取RAM实时价格的主要内容,如果未能解决你的问题,请参考以下文章