Tokens: ERC-20 and NFTs
Cactus expects tokens to implement the relevant standard, like ERC-20 or ERC-721. Also, Cactus needs the token contract to implement the EIP-5805 standard for delegation and voting power checkpointing.
Specifically, Cactus needs the following methods and event signatures for indexing and web3 calls:
Event signatures
Cactus’s API listens to event logs from token contracts when indexing them. Your token contract will need to maintain the same event signatures:
event DelegateVotesChanged(
address indexed delegate,
uint previousBalance,
uint newBalance
);
event DelegateChanged(
address indexed delegator,
address indexed fromDelegate,
address indexed toDelegate
);Your contract will need to support transfer events, too. Cactus works with both ERC20 transfer events and ERC721 events.
ERC20:
event Transfer(
address indexed from,
address indexed to,
uint256 amount
);
ERC721:
event Transfer(
address indexed from,
address indexed to,
uint256 indexed tokenId
);Function signatures
Your token contract also needs to implement voting and delegation functions. If you are using an ERC20 token, you can use the ERC20Votes extension from OpenZeppelin contracts library.
If you’re using an ERC71 token, you can use OpenZeppelin’s ERC721Votes extension.
The Cactus frontend helps users make these function calls to delegate their votes:
function delegate(address delegatee)
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
function getVotes(address account) uint256
function name() string
function symbol() string
// ERC20 only:
function decimals() public view returns (uint8) Name
The token contract must implement the name() function, so that Cactus knows what to call the token.
function name() stringSymbol
The token contract must implement a symbol() function, so that Cactus knows the short name of the token.
function symbol() stringDecimals
ERC20 token contracts must implement a decimals() function, so that Cactus can correctly render token balances:
function decimals() public view returns (uint8)