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

# On-Chain Programs

> Technical details of the Orica and Disputes Solana programs.

Orica consists of two Solana programs built with the Anchor framework. These programs handle all state mutations and fund movements.

***

## Program IDs

| Network | Orica Program | Disputes Program |
| - | - | - |
| Mainnet | `oEarJ8xDDssLcWwgkSpRVVbmiUyeDnoHFNAHPp6eetw` | `oVEzkDiY2FZP4ADfCeUfrg8jgCoMnPcVQao99indSqN` |

***

## Orica Program Instructions

> [accordion] initialize
>
> One-time setup to create the global state account.
>
> **Accounts:**
>
> * `authority`: Protocol authority (signer)
> * `globalState`: PDA for protocol config
> * `feeVault`: PDA for protocol fee collection
> * `usdcMint`: USDC token mint
>
> **Access:** Authority only

> [accordion] createMarket
>
> Creates a new prediction market.
>
> **Arguments:**
>
> * `creatorWallet`: Wallet to receive creator fees
> * `question`: Market question text
> * `metadataUri`: IPFS URI for metadata
> * `closeTime`: Unix timestamp when trading ends
> * `outcomeCount`: Number of outcomes
> * `optionNames`: Array of outcome names
>
> **Accounts:**
>
> * `admin`: Authorized admin (signer)
> * `market`: New market PDA
> * `marketVault`: New market vault PDA
>
> **Access:** Admin only

> [accordion] buy
>
> Purchase outcome shares.
>
> **Arguments:**
>
> * `amount`: USDC amount to spend
> * `outcomeIndex`: Index of outcome to buy
>
> **Accounts:**
>
> * `user`: Buyer (signer)
> * `userUsdc`: Buyer's USDC token account
> * `market`: Market being traded
> * `position`: User's position PDA (created if needed)
> * `marketVault`: Market's USDC vault
> * `feeVault`: Protocol fee vault
> * `creatorUsdc`: Creator's fee account
>
> **Access:** Public (market must be open)

> [accordion] sell
>
> Sell outcome shares back to the pool.
>
> **Arguments:**
>
> * `shares`: Number of shares to sell
> * `outcomeIndex`: Index of outcome to sell
>
> **Accounts:** Same as `buy`
>
> **Access:** Public (market must be open, user must have shares)

> [accordion] resolveMarket
>
> Report the winning outcome.
>
> **Arguments:**
>
> * `outcomeIndex`: Winning outcome (0-254) or 255 for unresolvable
> * `resolutionMetadataUri`: IPFS URI for resolution evidence
>
> **Accounts:**
>
> * `admin`: Authorized admin (signer)
> * `market`: Market being resolved
>
> **Access:** Admin only (market must be closed)

> [accordion] redeem
>
> Claim winnings from a resolved market.
>
> **Accounts:**
>
> * `user`: Position holder (signer)
> * `position`: User's position PDA
> * `market`: Resolved market
> * `marketVault`: Market's USDC vault
>
> **Access:** Public (market must be resolved, user must have winning shares)

***

## Disputes Program Instructions

> [accordion] voteForDispute
>
> Cast a vote in a dispute.
>
> **Accounts:**
>
> * `user`: Voter (signer)
> * `dispute`: Dispute PDA
> * `disputeVote`: User's vote PDA
> * `position`: User's market position (for weight)
>
> **Access:** Public (must have position in market)

> [accordion] postMessage
>
> Post a message to dispute discussion.
>
> **Arguments:**
>
> * `messageHash`: SHA-256 hash of content
> * `content`: Message text
> * `parentMessage`: Optional parent for threading
>
> **Accounts:**
>
> * `author`: Message author (signer)
> * `dispute`: Dispute PDA
> * `message`: New message PDA
> * `position`: Author's market position
>
> **Access:** Public (must have position in market)

> [accordion] boostMessage
>
> Boost another user's message.
>
> **Accounts:**
>
> * `booster`: User boosting (signer)
> * `message`: Message being boosted
> * `boostRecord`: PDA tracking the boost
> * `boosterPosition`: Booster's market position
>
> **Access:** Public (must have position, one boost per message)

> [accordion] resolveDispute
>
> Finalize a disputed market.
>
> **Arguments:**
>
> * `outcomeIndex`: Final outcome
> * `resolutionMetadataUri`: IPFS URI for resolution
>
> **Accounts:**
>
> * `resolver`: Authorized resolver (signer)
> * `dispute`: Dispute PDA
> * `market`: Market being resolved
>
> **Access:** Admin/Resolver only

***

## Program Derived Addresses

All accounts are PDAs derived deterministically from seeds:

```typescript theme={"dark"}
// Orica Program
globalState = ["global_state"]
feeVault = ["fee_vault"]
market = ["market", globalState, marketId]
marketVault = ["market_vault", globalState, marketId]
vaultAuthority = ["vault_authority", globalState, marketId]
position = ["position", market, user]

// Disputes Program
disputeConfig = ["dispute_config"]
dispute = ["dispute", market]
disputeVote = ["dispute_vote", dispute, user]
disputeMessage = ["message", dispute, author, messageCount]
boostRecord = ["boost_record", message, booster]
userAction = ["user_action", dispute, user]
```

***

## Next Steps

> [card] [Indexer](https://docs.orica.markets/guides/indexer.md)
>
> Learn how data is indexed off-chain.

> [card] [SDK PDA](https://docs.orica.markets/sdk/pda.md)
>
> Use the SDK to derive PDAs.


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