Skip to main content

useVote() function

Warning: This API is now obsolete.

This hook is deprecated and will be removed in a future major version. You should use instead.

- const vote = await sdk.useVote("0x1234...");
+ const vote = await sdk.useContract("0x1234...", "vote").contract;

Hook for getting an instance of an Vote contract. This contract enables fully featured voting-based decentralized governance systems.

Example

import { useVote } from '@thirdweb-dev/react'

export default function Component() {
const vote = useVote("<YOUR-CONTRACT-ADDRESS>")

// Now you can use the vote contract in the rest of the component

// For example, this function will get all the proposals on this contract
async function getProposals() {
const proposals = await vote.getAll()
return proposals
}

...
}

Signature:

export declare function useVote(
contractAddress: RequiredParam<string>,
): import("@thirdweb-dev/sdk").Vote | undefined;

Parameters

ParameterTypeDescription
contractAddressRequiredParam<string>the address of the Vote contract, found in your thirdweb dashboard

Returns:

import("@thirdweb-dev/sdk").Vote | undefined