Vote in a CTO

Participate in a Community Takeover vote by depositing tokens. Your vote weight equals the number of tokens deposited.

Cast Your Vote

const vote = new ethers.Contract(VOTE_CONTRACT, CTO_ABI, signer);
const token = new ethers.Contract(TOKEN_ADDRESS, ERC20_ABI, signer);

// Approve tokens to the vote contract
const amount = ethers.utils.parseUnits("1000000", 9);  // 1M tokens
await (await token.approve(VOTE_CONTRACT, amount)).wait();

// Vote YES
await (await vote.vote(amount, true)).wait();

// Or vote NO
// await (await vote.vote(amount, false)).wait();

Add More Votes

// Add tokens to existing vote (same direction)
const moreTokens = ethers.utils.parseUnits("500000", 9);
await (await token.approve(VOTE_CONTRACT, moreTokens)).wait();
await (await vote.add_votes(moreTokens)).wait();

Check Vote Status

const [yes, no, total, circulating, wouldPass] = await vote.get_vote_stats();
const participation = await vote.get_participation_percentage();
const timeLeft = await vote.time_remaining();

console.log("YES:", ethers.utils.formatUnits(yes, 9));
console.log("NO:", ethers.utils.formatUnits(no, 9));
console.log("Participation:", participation.toNumber(), "%");
console.log("Time left:", timeLeft.toNumber(), "seconds");
console.log("Would pass:", wouldPass);

End, Finalize & Withdraw

// End vote (after 3 days, or early if quorum+majority met)
await (await vote.end_vote()).wait();
// Or: await (await vote.end_vote_early()).wait();

// Finalize if successful
if (await vote.is_takeover_successful()) {
    await (await vote.finalize()).wait();
}

// Withdraw your tokens (always available after vote ends)
await (await vote.withdraw_tokens()).wait();