> ## 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.

# Dispute Messages

> Participating in dispute discussions.

Dispute messages allow participants to share evidence, arguments, and analysis. Messages are stored on-chain and weighted by the author's position.

***

## Message System

Messages in Orica disputes are:

* **On-chain**: Stored in Solana accounts for permanence
* **Weighted**: Author's position determines visibility
* **Boostable**: Others can boost messages they agree with
* **Threaded**: Replies can be linked to parent messages

***

## Posting a Message

**1. Prepare Content**

Write your message content. This will be stored on-chain, so be concise but clear.

**2. Generate Hash**

Create a SHA-256 hash of your content for verification.

```typescript theme={"dark"}
const encoder = new TextEncoder();
const data = encoder.encode(content);
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
const messageHash = Array.from(new Uint8Array(hashBuffer));
```

**3. Submit Transaction**

Build and send the message instruction.

```typescript theme={"dark"}
const [globalState] = sdk.orica.pda.globalState();
const [position] = sdk.orica.pda.position(marketAddress, wallet.publicKey);

const postIx = await sdk.disputes.buildPostMessage(
  wallet.publicKey,
  marketAddress,
  position,
  globalState,
  messageHash,
  content,
  null // No parent = top-level message
);
```

***

## Message Weight

Each message has a weight that determines its visibility:

$$
totalWeight = authorWeight + boostAmount
$$

* **Author Weight**: Based on the author's position value at post time
* **Boost Amount**: Sum of all boosts from other users

Messages are typically sorted by total weight, surfacing the most credible arguments.

***

## Boosting Messages

If you agree with someone's argument, you can boost their message:

```typescript theme={"dark"}
const messagePubkey = new PublicKey("Msg123...");
const [position] = sdk.orica.pda.position(marketAddress, wallet.publicKey);

const boostIx = await sdk.disputes.buildBoostMessage(
  wallet.publicKey,
  marketAddress,
  messagePubkey,
  position
);

const tx = new Transaction().add(boostIx);
await sendAndConfirmTransaction(connection, tx, [wallet]);
```

**Rules**:

* One boost per message per user
* Boost weight equals your position value
* Boosts cannot be withdrawn

***

## Threading

Reply to existing messages by specifying a parent:

```typescript theme={"dark"}
const parentMessage = new PublicKey("ParentMsg123...");

const replyIx = await sdk.disputes.buildPostMessage(
  wallet.publicKey,
  marketAddress,
  position,
  globalState,
  messageHash,
  content,
  parentMessage // Link to parent
);
```

***

## Fetching Messages

> [tab] By Weight (Default)
>
> ```bash theme={"dark"}
> curl "https://api.orica.markets/disputes/MARKET/messages?sort_by=weight"
> ```
>
> Returns messages sorted by total weight, most influential first.

> [tab] By Time
>
> ```bash theme={"dark"}
> curl "https://api.orica.markets/disputes/MARKET/messages?sort_by=timestamp"
> ```
>
> Returns messages in chronological order.

***

## Message Structure

```typescript theme={"dark"}
interface DisputeMessage {
  pubkey: string;           // On-chain account address
  market_address: string;   // Associated market
  author: string;           // Author's wallet
  parent_message: string | null;  // Parent for threading
  content: string;          // Message text
  author_weight: number;    // Author's position weight
  boost_amount: number;     // Total boosts received
  total_weight: number;     // author_weight + boost_amount
  is_admin: boolean;        // If author is admin
  timestamp: number;        // Unix timestamp
  message_index: number;    // For PDA derivation
}
```

***

## Best Practices

> [card] Be Factual
>
> Provide evidence and sources. Link to verifiable data when possible.

> [card] Be Concise
>
> On-chain storage has costs. Make your point clearly without unnecessary verbosity.

> [card] Boost Wisely
>
> Only boost messages you genuinely agree with. Your boost is permanent.

> [card] Respect the Process
>
> Focus on the facts of the dispute, not personal attacks.


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