Vote
Learn how to interact with your Vote contract in the SDK.
Create a Vote Contract
- React
- Javascript
- Python
- Go
- Unity
const sdk = useSDK();
const contractAddress = await sdk.deployer.deployVote({
name: "My Vote",
primary_sale_recipient: "your-address",
voting_token_address: "your-token-contract-address",
});
const contractAddress = await sdk.deployer.deployVote({
name: "My Vote",
primary_sale_recipient: "your-address",
voting_token_address: "your-token-contract-address",
});
This feature is missing a code snippet or might not be supported yet.
Check the Python SDK Reference for more information.
Reach out on Discord for further assistance!
This feature is missing a code snippet or might not be supported yet.
Check the Go SDK Reference for more information.
Reach out on Discord for further assistance!
This feature is missing a code snippet or might not be supported yet.
Check the Unity SDK Reference for more information.
Reach out on Discord for further assistance!
Getting the contract in your application
To start using your Vote contract inside your application, you'll need to use its contract address. You can get the contract address from the dashboard.
- React
- Javascript
- Python
- Go
- Unity
import { useContract } from '@thirdweb-dev/react'
export default function Component() {
const { contract } = useContract("<YOUR-CONTRACT-ADDRESS>", "vote")
// Now you can use the vote contract in the rest of the component
}
import { ThirdwebSDK } from "@thirdweb-dev/sdk";
const sdk = new ThirdwebSDK("{{chainName}}");
const contract = await sdk.getContract("{{contract_address}}", "vote");
This feature is missing a code snippet or might not be supported yet.
Check the Python SDK Reference for more information.
Reach out on Discord for further assistance!
This feature is missing a code snippet or might not be supported yet.
Check the Go SDK Reference for more information.
Reach out on Discord for further assistance!
// Vote is not yet supported in Unity. Reach out to us on Discord if you need this feature!
Multiwrap contract = sdk.GetContract("{{contract_address}}").vote
Creating A Proposal
- React
- Javascript
- Python
- Go
- Unity
// The description of the proposal you want to pass
const description = "This is a great proposal - vote for it!"
// You can (optionally) pass in contract calls that will get executed when the proposal is executed.
const executions = [
{
// The contract you want to make a call to
toAddress: "0x...",
// The amount of the native currency to send in this transaction
nativeTokenValue: 0,
// Transaction data that will be executed when the proposal is executed
// This is an example transfer transaction with a token contract (which you would need to setup in code)
transactionData: tokenContract.encoder.encode(
"transfer", [
fromAddress,
amount,
]
),
}
]
const proposal = await contract.propose(description, executions);
// The description of the proposal you want to pass
const description = "This is a great proposal - vote for it!"
// You can (optionally) pass in contract calls that will get executed when the proposal is executed.
const executions = [
{
// The contract you want to make a call to
toAddress: "0x...",
// The amount of the native currency to send in this transaction
nativeTokenValue: 0,
// Transaction data that will be executed when the proposal is executed
// This is an example transfer transaction with a token contract (which you would need to setup in code)
transactionData: tokenContract.encoder.encode(
"transfer", [
fromAddress,
amount,
]
),
}
]
const proposal = await contract.propose(description, executions);
This feature is missing a code snippet or might not be supported yet.
Check the Python SDK Reference for more information.
Reach out on Discord for further assistance!
This feature is missing a code snippet or might not be supported yet.
Check the Go SDK Reference for more information.
Reach out on Discord for further assistance!
// Vote is not yet supported in Unity. You can still use the contrat.Read and contract.Write functions to call functions directly.
Viewing Proposals
View all of the proposals that have been created in this Vote smart contract.
- React
- Javascript
- Python
- Go
- Unity
const proposals = await contract.getAll();
console.log(proposals);
const proposals = await contract.getAll();
console.log(proposals);
This feature is missing a code snippet or might not be supported yet.
Check the Python SDK Reference for more information.
Reach out on Discord for further assistance!
This feature is missing a code snippet or might not be supported yet.
Check the Go SDK Reference for more information.
Reach out on Discord for further assistance!
// Vote is not yet supported in Unity. You can still use the contrat.Read and contract.Write functions to call functions directly.
Check if a wallet has voted
Check if a wallet address has voted on a specific proposal.
- React
- Javascript
- Python
- Go
- Unity
// The proposal ID of the proposal you want to check
const proposalId = "0";
// The address of the wallet you want to check to see if they voted
const address = "{{wallet_address}}";
await contract.hasVoted(proposalId, address);
// The proposal ID of the proposal you want to check
const proposalId = "0";
// The address of the wallet you want to check to see if they voted
const address = "{{wallet_address}}";
await contract.hasVoted(proposalId, address);
This feature is missing a code snippet or might not be supported yet.
Check the Python SDK Reference for more information.
Reach out on Discord for further assistance!
This feature is missing a code snippet or might not be supported yet.
Check the Go SDK Reference for more information.
Reach out on Discord for further assistance!
// Vote is not yet supported in Unity. You can still use the contrat.Read and contract.Write functions to call functions directly.
Vote on a Proposal
- React
- Javascript
- Python
- Go
- Unity
// The proposal ID of the proposal you want to vote on
const proposalId = "0";
// The vote type you want to cast, can be VoteType.Against, VoteType.For, or VoteType.Abstain
const voteType = VoteType.For;
// The (optional) reason for the vote
const reason = "I like this proposal!";
await contract.vote(proposalId, voteType, reason);
// The proposal ID of the proposal you want to vote on
const proposalId = "0";
// The vote type you want to cast, can be VoteType.Against, VoteType.For, or VoteType.Abstain
const voteType = VoteType.For;
// The (optional) reason for the vote
const reason = "I like this proposal!";
await contract.vote(proposalId, voteType, reason);
This feature is missing a code snippet or might not be supported yet.
Check the Python SDK Reference for more information.
Reach out on Discord for further assistance!
This feature is missing a code snippet or might not be supported yet.
Check the Go SDK Reference for more information.
Reach out on Discord for further assistance!
// Vote is not yet supported in Unity. You can still use the contrat.Read and contract.Write functions to call functions directly.
Check if a proposal can be executed
Check to see if the amount of votes required for the proposal to be executed has been met.
- React
- Javascript
- Python
- Go
- Unity
// The proposal ID of the proposal you want to check
const proposalId = "0";
const canExecute = await contract.canExecute(proposalId);
console.log(canExecute);
// The proposal ID of the proposal you want to check
const proposalId = "0";
const canExecute = await contract.canExecute(proposalId);
console.log(canExecute);
This feature is missing a code snippet or might not be supported yet.
Check the Python SDK Reference for more information.
Reach out on Discord for further assistance!
This feature is missing a code snippet or might not be supported yet.
Check the Go SDK Reference for more information.
Reach out on Discord for further assistance!
// Vote is not yet supported in Unity. You can still use the contrat.Read and contract.Write functions to call functions directly.
Execute a proposal
Execute a proposal that has a sufficient amount of votes.
- React
- Javascript
- Python
- Go
- Unity
// The proposal ID ofthe proposal you want to execute
const proposalId = "0"
await contract.execute(proposalId);
// The proposal ID ofthe proposal you want to execute
const proposalId = "0"
await contract.execute(proposalId);
This feature is missing a code snippet or might not be supported yet.
Check the Python SDK Reference for more information.
Reach out on Discord for further assistance!
This feature is missing a code snippet or might not be supported yet.
Check the Go SDK Reference for more information.
Reach out on Discord for further assistance!
// Vote is not yet supported in Unity. You can still use the contrat.Read and contract.Write functions to call functions directly.