I would like to calculate the threshold for referendums to pass. I found this article about how the calculation works, but it requires the number of coins in circulation. Is there an API endpoint for this?


1 Answer 1


Vote Threshold

Let's take a look at the calculation/formula first.

There are 3 kinds of VoteThreshold, so the first thing you need to figure out is the voting type.

Bake Referendum

Then, the previous function was called here.

Through the code, we know that we need two storage items to finish the calculation.

  1. ReferendumInfoOf contains voting type and tally/supply
  2. TotalIssuance is the electorate

You just need to query balances::total_issuance and democracy::referendum_info_of(x). And fill them in the formula.

Tips: for the compare_rationals. It's well documented in the source code.

It's just n1 / d1 < n2 / d2 but with some overflowing protection.

If you are off-chain, using f64/double is enough. IIUC.

  • Perfect, worked like a charm
    – Tum
    Sep 1, 2022 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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