0

When I cast a vote on a referendum with a value as

let vote = { 
    Standard: {
      vote: {                                                                                                                           
        aye: true,                                                                                                                                                                      
        conviction: 'Locked4x',                                                                                                                                                              
      },
      balance: balance
    }
  };

  let unsub = await api.tx.democracy.vote(i, vote).signAndSend(payoutKey, ...);

Through the event I have extracted the following data

[
AccountId32: 5HeM14aFJPKxi...vVyV7oX6rErJhN,
u32: 79,
{"_enum":{"Standard":"{"vote":"Vote","balance":"u128"}","Split":"{"aye":"u128","nay":"u128"}"}}: {"standard":{"vote":"0x01","balance":"0x0000000000000000c249fdd327780000"}}]

We realize that it does not contain the vote conviction.

I tried to look it up via api.query.democracy.votingOf(accountId)

But unfortunately, every vote returns the same value {conviction: "Locked1x", vote: "Nay"}

Even if the actual values are entirely different. Eg: conviction is Locked4x and vote is Aye

enter image description here

The questions are:

  1. How to get the conviction value of a democratic vote?
  2. Why does api.query.democracy.votingOf always return the same value {conviction: "Locked1x", vote: "Nay"}

1 Answer 1

1

The api.query.democracy.votingOf is the right way to get the conviction value, it should not always return the same value {conviction: "Locked1x", vote: "Nay"}

An example:

See this referendum on Polkadot: https://polkadot.polkassembly.io/referendum/95

The address 1hbyB383QeqwGNAHj439MKSnx3JMM1fzrXMAPtNfn6v3Smz has placed 10 DOT with a 6x Conviction (see below the image from Polkassembly)

With this code:

const wsProvider = new WsProvider('wss://rpc.polkadot.io')
const api = await ApiPromise.create({ provider: wsProvider });

const votesOf = await api.query.democracy.votingOf("1hbyB383QeqwGNAHj439MKSnx3JMM1fzrXMAPtNfn6v3Smz");
console.log(`${JSON.stringify(votesOf.toHuman())}`);

We get the list of votes, and we can see that in the referendum with id 95 it has voted {"conviction":"Locked6x","vote":"Aye"} :

{"Direct":{"votes":[["95",{"Standard":{"vote":{"conviction":"Locked6x","vote":"Aye"},"balance":"100,000,000,000"}}]],"delegations":{"votes":"0","capital":"0"},"prior":["0","0"]}}

enter image description here

To know what can be wrong with your response, which is the id of the referendum where you are voting? and the address of the voter? and in which network are you voting?

Your Answer

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

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