0

In my blockchain, there are 4 accounts registered as block producers. accountnum1 vote for each of them. cleos system listproducers returns

Producer      Producer key    Url                          Scaled votes                
accountnum1   key1            https://accountnum1.com      0.2500
accountnum2   key2            https://accountnum2.com      0.2500
accountnum3   key3            https://accountnum3.com      0.2500
accountnum4   key4            https://accountnum4.com      0.2500

I need this information using Eos-sharp API. I tried following c# code to get it:

var prodList = await r.GetProducers(new EosSharp.Core.Api.v1.GetProducersRequest()
{
   json = true,
   lower_bound = "1",
   limit = 10
});

This returns Vote information for each producer account as 5775596249181922304.00000000000000000. How can I convert it into simplified one as Scaled votes 0.2500?

2
  • You can use the producers table on the eosio system contract bloks.io/account/…
    – Nat
    May 26 at 10:16
  • But this also returns "total_votes": "5775596249181922304.00000000000000000".
    – Varsh
    May 26 at 10:34
1

You can get the total vote weight

curl -sd '{"scope":"eosio", "code":"eosio", "table":"global", "json": true}' http://api.eosn.io/v1/chain/get_table_rows | jq '.rows[0].total_producer_vote_weight'

Then you can divide each row in th producer table by that number to get the fraction

curl -sd '{"scope":"eosio", "code":"eosio", "table":"producers", "json":true, "limit":10000}' http://api.eosn.io/v1/chain/get_table_rows | jq '.rows[] | "\(.owner) \(.total_votes)"'

I'm not familiar with the EOS-Sharp library, but presumably there is a GetTable() method or similar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.