0

I am trying to assemble a list of all voters on a referendum with their votes, etc. I need help on what storage pallet to call, I tried calling the functions on the convictionVoting pallet which is not working for me.

1 Answer 1

0

Here are some snippets that may help you get started:

const votes = await api.query.convictionVoting.votingFor.entries();
votes.forEach((vote) => {
    if (vote[1].toHuman()['Casting']) {
        if (vote[1].toHuman()['Casting']['votes'].length > 0) {
            console.log(vote[0].toHuman());
            console.log(JSON.stringify(vote[1].toHuman(), null, 4));
        }
    }
});
const referenda = await api.query.referenda.referendumInfoFor.entries();
referenda.forEach(async (referendum) => {
    if (referendum[1].toHuman()['Ongoing']) {
        const referendumIndex = referendum[0].args[0].toNumber();
        console.log("Referendum:", referendumIndex);
        console.log(referendum[1].toJSON());
    }
});

Resources

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.