> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orica.markets/llms.txt
> Use this file to discover all available pages before exploring further.

# Voting

> Cast votes in dispute resolution.

Voting allows position holders to influence dispute outcomes.

***

## Vote for Dispute

Cast a vote supporting the dispute:

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> const [globalState] = sdk.orica.pda.globalState();
> const [position] = sdk.orica.pda.position(marketAddress, wallet.publicKey);
>
> const instruction = await sdk.disputes.buildVoteForDispute(
>   wallet.publicKey,
>   marketAddress,
>   position,
>   globalState
> );
>
> const tx = new Transaction().add(instruction);
> await sendAndConfirmTransaction(connection, tx, [wallet]);
> ```

> [tab] Python
>
> ```python theme={"dark"}
> global_state, _ = sdk.orica.pda.global_state()
> position, _ = sdk.orica.pda.position(market_address, wallet.pubkey())
>
> instruction = await sdk.disputes.build_vote_for_dispute(
>     user=wallet.pubkey(),
>     market=market_address,
>     position=position,
>     global_state=global_state,
> )
>
> tx = Transaction()
> tx.add(instruction)
> await connection.send_transaction(tx, wallet)
> ```

> [!NOTE]
>
> Your voting weight is determined by the value of your position in the market.

***

## Fetch User's Vote

Check if a user has voted:

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> const [dispute] = sdk.disputes.pda.dispute(marketAddress);
> const vote = await sdk.disputes.fetchDisputeVote(dispute, userPubkey);
>
> if (vote) {
>   console.log("Vote weight:", vote.weight.toString());
> } else {
>   console.log("User has not voted");
> }
> ```

> [tab] Python
>
> ```python theme={"dark"}
> dispute, _ = sdk.disputes.pda.dispute(market_address)
> vote = await sdk.disputes.fetch_dispute_vote(dispute, user_pubkey)
>
> if vote:
>     print(f"Vote weight: {vote.weight}")
> else:
>     print("User has not voted")
> ```

***

## Fetch All Votes (TypeScript)

Get all votes for a dispute:

```typescript theme={"dark"}
const [dispute] = sdk.disputes.pda.dispute(marketAddress);
const votes = await sdk.disputes.fetchDisputeVotes(dispute);

let totalWeight = new BN(0);
for (const { publicKey, account } of votes) {
  console.log("Voter:", account.user.toBase58());
  console.log("Weight:", account.weight.toString());
  totalWeight = totalWeight.add(account.weight);
}

console.log("Total vote weight:", totalWeight.toString());
```

***

## Vote Structure

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> interface DisputeVote {
>   dispute: PublicKey;
>   user: PublicKey;
>   weight: BN;
>   bump: number;
> }
> ```

> [tab] Python
>
> ```python theme={"dark"}
> @dataclass
> class DisputeVote:
>     dispute: Pubkey
>     user: Pubkey
>     weight: int
>     bump: int
> ```

***

## Voting Rules

* Each user can vote once per dispute
* Vote weight equals position value at time of voting
* Votes cannot be changed or withdrawn
* Threshold is >50% of total pool weight

***

## Next Steps

> [card] [Messages](https://docs.orica.markets/sdk/messages.md)
>
> Post and boost discussion messages.

> [card] [PDA Reference](https://docs.orica.markets/sdk/pda.md)
>
> Understand PDA derivation.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.