Skip to main content

Query Delegation

This page covers how to fetch delegation data from the DAO Café GraphQL API. Endpoint: https://dao.cafe/graphql

How Delegation Works

In governance tokens (ERC20Votes), holders can delegate their voting power to another address:
  • Delegator: The address that owns tokens and delegates voting power
  • Delegate: The address that receives voting power and can vote
Self-delegation is common — users must delegate to themselves to activate their voting power.

Get Delegations by DAO

Fetch all delegation relationships in a DAO.
query GetDAODelegations($daoId: String!) {
  delegates(where: { daoId: $daoId }, limit: 100) {
    items {
      delegator
      toDelegate
      token
      updatedAt
    }
  }
}

Get Delegations by Delegator

Find who a specific address has delegated to.
query GetDelegationsByDelegator($delegator: String!) {
  delegates(where: { delegator: $delegator }) {
    items {
      daoId
      token
      toDelegate
      updatedAt
    }
  }
}
This query shows which addresses a user has delegated their voting power to across all DAOs.

Get Delegations to a Delegate

Find all addresses that have delegated to a specific delegate.
query GetDelegationsToDelegate($toDelegate: String!, $daoId: String!) {
  delegates(where: { toDelegate: $toDelegate, daoId: $daoId }) {
    items {
      delegator
      token
      updatedAt
    }
  }
}
This is useful for finding all the delegators backing a specific delegate.

Check if Address Has Delegated

Check if a specific address has delegated in a specific DAO.
query CheckDelegation($delegator: String!, $daoId: String!) {
  delegates(where: { delegator: $delegator, daoId: $daoId }) {
    items {
      toDelegate
      updatedAt
    }
  }
}

Get Top Delegates

Find addresses receiving the most delegations. Combine with token holder data for voting power.
query GetTopDelegates($daoId: String!) {
  tokenHolders(
    where: { daoId: $daoId }
    orderBy: "votes"
    orderDirection: "desc"
    limit: 20
  ) {
    items {
      holder
      balance
      votes
    }
  }
}
Addresses with votes > balance have received delegations from others.

Get Delegation with DAO Context

Fetch delegations along with DAO information.
query GetDelegationsWithDAO($delegator: String!) {
  delegates(where: { delegator: $delegator }) {
    items {
      toDelegate
      updatedAt
      dao {
        id
        name
        tokenSymbol
      }
    }
  }
}

Get Recent Delegation Changes

Find the most recent delegation updates.
query GetRecentDelegations($daoId: String!) {
  delegates(
    where: { daoId: $daoId }
    orderBy: "updatedAt"
    orderDirection: "desc"
    limit: 20
  ) {
    items {
      delegator
      toDelegate
      updatedAt
      blockNumber
    }
  }
}

Available Delegate Fields Reference

FieldTypeDescription
idStringComposite ID: chainId_token_delegator
daoIdStringReference to DAO
chainIdIntNetwork chain ID
tokenAddressToken contract
delegatorAddressAddress delegating
toDelegateAddressAddress receiving delegation
updatedAtBigIntLast update timestamp
blockNumberBigIntLast update block
transactionHashHexLast update tx hash