---
eip: 5805
label: ERC-5805
title: Voting with delegation
status: Review
type: Standards Track
category: ERC
created: 2022-07-04
requires: 712, 6372
official: https://eips.ethereum.org/EIPS/eip-5805
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5805.md
canonical: https://eips.huatuo.xyz/eip-5805/
lang: en
tldr: Standardizes the delegate-and-checkpoint interface that governance tokens use, so any Governor can read past voting power from any token, whether it counts time in blocks or in seconds.
tags: [governance, dao, voting, delegation, token]
---

# ERC-5805: Voting with delegation

> An interface for voting weight tracking, with delegation support

**TL;DR:** Standardizes the delegate-and-checkpoint interface that governance tokens use, so any Governor can read past voting power from any token, whether it counts time in blocks or in seconds.

## What problem does it solve?

DAOs often weight votes by token holdings. Using plain `balanceOf` for that is broken in two ways:

- **Double voting.** Balances are not snapshotted, so you can vote, move the tokens to another address, and vote again.
- **No delegation.** You cannot let someone else vote with your tokens without handing the tokens over.

Compound's COMP token introduced the fix that became common practice: delegation plus per-account vote checkpoints. Many tokens copied it, but there was no standard, and the existing versions only counted time in block numbers, which is awkward on L2s with irregular block times. ERC-5805 writes down the interface and behaviour, and lets the token choose its clock.

## How it works

- Every account picks one **delegate**: itself, someone else, or nobody (`address(0)`). Tokens only count as votes once delegated. Delegating to yourself is needed if you want to vote directly.
- The token keeps a history (checkpoints) of each delegate's voting power. Delegation changes and transfers move voting power from one delegate to another and emit `DelegateVotesChanged`; delegation changes emit `DelegateChanged`.
- Reads:
  - `getVotes(account)` — current voting power;
  - `getPastVotes(account, timepoint)` — voting power at a past timepoint. Asking about the current or a future timepoint should revert; past values must never change;
  - `delegates(account)` and `nonces(account)`.
- Writes: `delegate(delegatee)` and `delegateBySig(delegatee, nonce, expiry, v, r, s)`, a gasless version using an [EIP-712](/eip-712/) `Delegation(address delegatee,uint256 nonce,uint256 expiry)` signature that anyone can submit.
- **Clock.** Tokens should implement [ERC-6372](/eip-6372/) (`clock()` and `CLOCK_MODE()`) to say whether timepoints are block numbers or timestamps. Without ERC-6372, block numbers are assumed.

A Governor takes a snapshot timepoint when a proposal is created, then counts each voter's `getPastVotes` at that timepoint. Tokens bought or moved afterwards do not change the outcome.

## Sample code

Using OpenZeppelin's `ERC20Votes`, which follows this interface, with a timestamp clock:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {ERC20, ERC20Permit, ERC20Votes, Nonces} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol";

contract GovToken is ERC20, ERC20Permit, ERC20Votes {
    constructor() ERC20("Gov", "GOV") ERC20Permit("Gov") {
        _mint(msg.sender, 1_000_000e18);
    }

    // ERC-6372: count time in seconds instead of blocks
    function clock() public view override returns (uint48) { return uint48(block.timestamp); }
    function CLOCK_MODE() public pure override returns (string memory) { return "mode=timestamp"; }

    function _update(address from, address to, uint256 v) internal override(ERC20, ERC20Votes) {
        super._update(from, to, v);
    }
    function nonces(address o) public view override(ERC20Permit, Nonces) returns (uint256) {
        return super.nonces(o);
    }
}
```

Activating your votes and reading them (ethers v6):

```ts
await token.delegate(myAddress);          // self-delegate once
const now = await token.getVotes(myAddress);
const mode = await token.CLOCK_MODE();    // "mode=timestamp" or "mode=blocknumber&from=default"
const past = await token.getPastVotes(myAddress, snapshotTimepoint);
```

## Things to know

- **Status: Review.** It is not Final, although the pattern it describes is already widely deployed (Compound-style and OpenZeppelin vote tokens).
- Holding tokens is not enough; you must delegate (often to yourself) before the snapshot, or your tokens carry no votes.
- Check `clock()` / `CLOCK_MODE()` before querying. Passing a timestamp to a block-number token will likely revert, and a block number to a timestamp token will likely return 0.
- `delegateBySig` must reject a zero recovered signer, otherwise malformed signatures could delegate "the zero address's" balance.
- A relayer holding your signed delegation can choose not to submit it; the `expiry` field limits how long it stays usable.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-5805
