EOS获取计算RAM价格

 

获取RAM价格

方式1)命令行中输入:

cleos -u http://nodes.get-scatter.com:80 get table eosio eosio rammarket

方式2)使用eosjs:

eos.getTableRows({"json": true,"code": "eosio","scope":"eosio","table":"rammarket"}).then(rs => console.log(rs));

结果:

{
  "rows": [{
      "supply": "10000000000.0000 RAMCORE",
      "base": {
        "balance": "26352582837 RAM",
        "weight": "0.50000000000000000"
      },
      "quote": {
        "balance": "2607707.4971 EOS",
        "weight": "0.50000000000000000"
      }
    }
  ],
  "more": false
}

然后使用Bancor算法,计算出需要nKB的RAM的价格:

RAM价格 = (n * quote.balance) / (n + base.balance / 1024)

猜你喜欢

转载自blog.csdn.net/weixin_39842528/article/details/81098428