Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Conversation

@abysnart
Copy link

xSGT NFT Voting Power Strategy

Overview

This PR introduces a new voting strategy for NFTs where each token ID has a specific voting power. The strategy is useful for NFT-based governance where different token IDs carry different voting weights.

Use Case

The strategy enables Snapshot spaces to support voting with NFTs where:

  • A user may hold multiple NFTs with different token IDs
  • Each token ID can have a different, predefined voting power (e.g., token ID 1 = 1 vote, token ID 2 = 9 votes)
  • The voting power for each token ID is stored in the NFT contract itself

Contract Requirements

The NFT contract must implement:

  • tokensOfOwner(address _owner) external view returns (uint256[]) - Gets all token IDs owned by an address
  • getVotingPower(uint256 _tokenId) external view returns (uint256) - Gets the voting power for a specific token ID

Implementation Details

The strategy:

  1. Retrieves all token IDs owned by each voting address
  2. Fetches the voting power for each token ID from the contract
  3. Sums up the total voting power per address

Testing

I've tested this strategy with the xSGT NFT contract (at address 0x...) and confirmed that it correctly calculates voting power based on token ID weightings.

Changes

  • Added strategy TypeScript file
  • Added schema.json for configuration validation
  • Added example.json for reference implementation

Thank you for reviewing!

@ChaituVR ChaituVR changed the title feat: erc721-contract-call [erc721-contract-call] feat: erc721-contract-call Mar 19, 2025
{
"name": "xSGT NFT Voting Power Example",
"strategy": {
"name": "xsgt-nft-voting-power",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be same as strategy name

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually the name xsgt-nft-voting-power makes more sense than erc721-contract-call

@@ -0,0 +1,105 @@
import { formatUnits } from '@ethersproject/units';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint / tests are failing in this fail, could take a look?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants