Skip to main content

Query Votes & Voting Power

This page covers how to fetch vote data and check voting power from the DAO Café GraphQL API. Endpoint: https://dao.cafe/graphql

Get Votes by Proposal

Fetch all votes cast on a specific proposal.
query GetVotesByProposal($proposalId: String!) {
  votes(where: { proposalId: $proposalId }, orderBy: "weight", orderDirection: "desc") {
    items {
      id
      voter
      support
      weight
      reason
      createdAt
    }
  }
}

Get Votes by Voter

Find all votes cast by a specific address across all proposals.
query GetVotesByVoter($voter: String!) {
  votes(where: { voter: $voter }, orderBy: "createdAt", orderDirection: "desc") {
    items {
      id
      proposalId
      daoId
      support
      weight
      reason
      createdAt
    }
  }
}

Get Votes by Support Type

Filter votes by how they voted.

FOR Votes

query GetForVotes($proposalId: String!) {
  votes(where: { proposalId: $proposalId, support: FOR }) {
    items {
      voter
      weight
      reason
    }
  }
}

AGAINST Votes

query GetAgainstVotes($proposalId: String!) {
  votes(where: { proposalId: $proposalId, support: AGAINST }) {
    items {
      voter
      weight
      reason
    }
  }
}

ABSTAIN Votes

query GetAbstainVotes($proposalId: String!) {
  votes(where: { proposalId: $proposalId, support: ABSTAIN }) {
    items {
      voter
      weight
      reason
    }
  }
}
Support types: FOR, AGAINST, ABSTAIN

Check Voting Power

Query token holders to check voting power for a specific address.

Get Voting Power for Address

query GetVotingPower($daoId: String!, $holder: String!) {
  tokenHolders(where: { daoId: $daoId, holder: $holder }) {
    items {
      holder
      balance
      votes
      updatedAt
    }
  }
}
The votes field represents the actual voting power (may differ from balance due to delegation).

Get Top Voters by Voting Power

Find the addresses with the most voting power in a DAO.
query GetTopVoters($daoId: String!) {
  tokenHolders(
    where: { daoId: $daoId }
    orderBy: "votes"
    orderDirection: "desc"
    limit: 20
  ) {
    items {
      holder
      balance
      votes
    }
  }
}

Get Top Token Holders by Balance

Find the addresses with the most tokens (may differ from voting power).
query GetTopHolders($daoId: String!) {
  tokenHolders(
    where: { daoId: $daoId }
    orderBy: "balance"
    orderDirection: "desc"
    limit: 20
  ) {
    items {
      holder
      balance
      votes
    }
  }
}

Get All Token Holders with Voting Power

Find all addresses that have voting power > 0.
query GetActiveVoters($daoId: String!) {
  tokenHolders(
    where: { daoId: $daoId }
    orderBy: "votes"
    orderDirection: "desc"
    limit: 100
  ) {
    items {
      holder
      votes
    }
  }
}

Available Vote Fields Reference

FieldTypeDescription
idStringComposite ID
proposalIdStringReference to proposal
daoIdStringReference to DAO
chainIdIntNetwork chain ID
governorAddressGovernor contract
voterAddressVoter address
supportEnumFOR, AGAINST, ABSTAIN
weightBigIntVoting power used
reasonStringVote reason (optional)
paramsHexExtra params (optional)
createdAtBigIntVote timestamp
blockNumberBigIntVote block
transactionHashHexVote tx hash

Available Token Holder Fields Reference

FieldTypeDescription
idStringComposite ID
daoIdStringReference to DAO
chainIdIntNetwork chain ID
tokenAddressToken contract
holderAddressHolder address
balanceBigIntToken balance
votesBigIntVoting power
updatedAtBigIntLast update
blockNumberBigIntLast update block