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

# Messages

> Post messages in dispute forums.

Dispute messages allow position holders to present arguments during dispute resolution.

***

## Post a Message

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> const content = "The resolution is incorrect because...";
>
> // Create message hash
> const encoder = new TextEncoder();
> const hashBuffer = await crypto.subtle.digest('SHA-256', encoder.encode(content));
> const messageHash = Array.from(new Uint8Array(hashBuffer));
>
> const [globalState] = sdk.orica.pda.globalState();
> const [position] = sdk.orica.pda.position(marketAddress, wallet.publicKey);
>
> const instruction = await sdk.disputes.buildPostMessage(
>   wallet.publicKey,
>   marketAddress,
>   position,
>   globalState,
>   messageHash,
>   content,
>   null // No parent message (top-level)
> );
>
> const tx = new Transaction().add(instruction);
> await sendAndConfirmTransaction(connection, tx, [wallet]);
> ```

> [tab] Python
>
> ```python theme={"dark"}
> import hashlib
>
> content = "The resolution is incorrect because..."
> ipfs_uri = "ipfs://..."  # Store content on IPFS first
>
> # Create message hash
> message_hash = hashlib.sha256(content.encode()).digest()
>
> global_state, _ = sdk.orica.pda.global_state()
> position, _ = sdk.orica.pda.position(market_address, wallet.pubkey())
>
> instruction = await sdk.disputes.build_post_message(
>     author=wallet.pubkey(),
>     market=market_address,
>     position=position,
>     global_state=global_state,
>     message_hash=message_hash,
>     ipfs_uri=ipfs_uri,
>     parent_message=None,  # No parent (top-level)
> )
>
> tx = Transaction()
> tx.add(instruction)
> await connection.send_transaction(tx, wallet)
> ```

***

## Reply to a Message

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> const parentMessagePubkey = new PublicKey("ParentMessage123...");
>
> const instruction = await sdk.disputes.buildPostMessage(
>   wallet.publicKey,
>   marketAddress,
>   position,
>   globalState,
>   messageHash,
>   content,
>   parentMessagePubkey // Reply to this message
> );
> ```

> [tab] Python
>
> ```python theme={"dark"}
> parent_message = Pubkey.from_string("ParentMessage123...")
>
> instruction = await sdk.disputes.build_post_message(
>     author=wallet.pubkey(),
>     market=market_address,
>     position=position,
>     global_state=global_state,
>     message_hash=message_hash,
>     ipfs_uri=ipfs_uri,
>     parent_message=parent_message,  # Reply to this message
> )
> ```

***

## Fetch Dispute Messages

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> const [dispute] = sdk.disputes.pda.dispute(marketAddress);
> const messages = await sdk.disputes.fetchDisputeMessages(dispute);
>
> for (const { publicKey, account } of messages) {
>   console.log("Author:", account.author.toBase58());
>   console.log("Content:", account.content);
>   console.log("Timestamp:", new Date(account.timestamp.toNumber() * 1000));
>   console.log("Author Weight:", account.authorWeight.toString());
>   console.log("Boost Amount:", account.boostAmount.toString());
>   console.log("Is Admin:", account.isAdmin);
> }
> ```

> [tab] Python
>
> ```python theme={"dark"}
> dispute, _ = sdk.disputes.pda.dispute(market_address)
> messages = await sdk.disputes.fetch_dispute_messages(dispute)
>
> for address, message in messages:
>     print(f"Author: {message.author}")
>     print(f"IPFS URI: {message.ipfs_uri}")
>     print(f"Timestamp: {message.timestamp}")
>     print(f"Author Weight: {message.author_weight}")
>     print(f"Boost Amount: {message.boost_amount}")
>     print(f"Is Admin: {message.is_admin}")
> ```

***

## Message Structure

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> interface DisputeMessage {
>   dispute: PublicKey;
>   author: PublicKey;
>   parentMessage: PublicKey | null;
>   messageHash: number[];
>   content: string;
>   timestamp: BN;
>   authorWeight: BN;
>   boostAmount: BN;
>   isAdmin: boolean;
>   bump: number;
> }
> ```

> [tab] Python
>
> ```python theme={"dark"}
> @dataclass
> class DisputeMessage:
>     dispute: Pubkey
>     author: Pubkey
>     parent_message: Pubkey | None
>     message_hash: bytes
>     ipfs_uri: str
>     timestamp: int
>     author_weight: int
>     boost_amount: int
>     is_admin: bool
>     bump: int
> ```

***

## Message Requirements

* Must have a position in the market to post
* Author weight reflects position value at time of posting
* Message hash ensures content integrity
* Replies link to parent messages

***

## Next Steps

> [card] [Boosting](https://docs.orica.markets/sdk/boosting.md)
>
> Boost important messages.

> [card] [Disputes](https://docs.orica.markets/sdk/disputes.md)
>
> Back to disputes overview.


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