Leprechaun avatar

POB to Ecency: Day 14 - Getting the Data together for calculating the vote worth

leprechaun

Published: 29 May 2021 › Updated: 29 May 2021POB to Ecency: Day 14 - Getting the Data together for calculating the vote worth

POB to Ecency: Day 14 - Getting the Data together for calculating the vote worth

Today I got a little bit closer to getting vote reward calculations right in Proof of Brain.

VotingWith1TrillionPOBPoweredUp.png

The calculation of voting reward requires five requests.
One is the balances of an account from :
https://api.hive-engine.com/rpc , you specify you want the token balances like this:

 curl -XPOST -H "Content-type: application/json" -d '{ "jsonrpc": "2.0", "method": "find", "params": { "contract": "tokens", "table": "balances", "query": { "symbol": "POB", "account": "leprechaun"}, "limit":1, "offset": 0 }, "id": 1 }' 'https://api.hive-engine.com/rpc/contracts'

Then you need to get information about the POB token

curl -XGET 'https://scot-api.hive-engine.com/info?token=POB&hive=1'

and

curl -XGET 'https://scot-api.hive-engine.com/config?token=POB&hive=1'

Then finally the various vote amounts in the POB way of seeing things:

curl -XGET 'https://scot-api.hive-engine.com/@achimmertens/weekly-statistics-for-the-dollarpob-token-qttbs0?hive=1'

This call gets you the POB price in Hive.

curl -XPOST -H "Content-type: application/json" -d '{ "jsonrpc": "2.0", "method": "find", "params": { "contract": "market", "table": "tradesHistory", "query": { "symbol": "POB"}, "limit":1, "offset": 0 }, "id": 1 }' 'https://api.hive-engine.com/rpc/contracts'

Then there is a Hive call to get the price of Hive in Dollars

curl -XPOST -H "Content-type: application/json" -d '{"jsonrpc":"2.0", "method":"database_api.get_dynamic_global_properties", "id":1}' 'https://api.hive.blog'

You can now put all of the data together yourself, and calculate the amount you should get for voting. The exact way this is calculated is done at src/app/components/elements/Voting.jsx
in the github repo: https://github.com/hive-engine/nitrous.

That is if you're really bored some day. :)

Leave POB to Ecency: Day 14 - Getting the Data together for calculating the vote worth to:

Written by

An Economist, a Coder and a Carbonist. Author of https://Steemfiles.com, Author of https://ProofofBrain.blog Carbonist community admin (https://www.proofofbrain.blog/created/hive-139995). Discord: leprechaun#2185 Email: theleprechaun2022@steemfiles.com Lover of freedom

Read more #hive-150329 posts


Best Posts From Leprechaun

We have not curated any of leprechaun'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 Leprechaun