Self-delegation in ERC20Votes


I'm using the ERC20Votes extension for my ERC20 token and I would like to assign balance = voting power.

If I understood the documentation correctly, in order to have your voting power = token balance, each wallet should self delegate itself.

By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked. Enabling self-delegation can easily be done by overriding the delegates function. Keep in mind however that this will significantly increase the base gas cost of transfers. (source)

Should this happen only once in order to activate checkpoints?

It's still not really clear on how this should work.
If someone has an example of a Token implementation that has balance=voting power, that would be awesome!

Thanks for your time!

Yeah, if you want voting power = token balance, you should delegate to yourself.
And if you only want to delegate to yourself, yes, you just need to do this once.

1 Like

The token will have multiple holders and lots of transfers.
I still don't understand if I should self-delegate to each new holder or only once to the owner of the token.

Do you have any example of an implementation of the self-delegate part?

When a user receives the ERC20 token that has the ERC20Votes extension (like buying from a CEX or trading for them in a DEX), they simply have to submit a transaction to the token contract to the function delegate(address delegatee) (similar concept to calling the approve function). The user will put their wallet address in for the delegatee argument to self delegate. Then, as long as the user holds their ERC20 tokens, they will retain the votes they delegate to themselves through this delegate transaction.


If you want to automatically trigger self-delegation for everyone, you could override _mint or _beforeTokenTransfer to add a call to _delegate.

1 Like

I was wondering what is the better use case than token balance to have it as voting power ?

Why wouldn't I want to call delegate for each user so that their accounts can be in the checkpoints and then use my voting contract to account for this ?

I guess, the only use case I can think of is that if users that don't participate in the voting, they don't need to call delegate and that's it, right ? @frangio

Checkpoints are expensive book-keeping. It wouldn't make sense for a Uniswap Pair contract to track its balance checkpoints, for example, or an arbitrage bot. So delegation is opt-in as an optimization.