Creating Optimistic Queries

Creating an optimistic query allows you to get fast, low-cost answers to questions.

Requirements

  • 30,000 $TRUTH tokens (creation cost)
  • Approved token spending for the OptimisticOracle contract
  • A clear question and 2-254 answer options

Step by Step

1. Approve Token Spending

import { ethers } from 'ethers'

const TOKEN_ADDRESS = '0x948d7a6f18511df422184360d1cd5d56f5be4444'
const OPTIMISTIC_ORACLE_ADDRESS = '0xA83689161DFa9d5992fBa658d3148C6f72E1419E'
const CREATION_COST = ethers.parseEther('30000')

const tokenContract = new ethers.Contract(TOKEN_ADDRESS, TOKEN_ABI, signer)
const tx = await tokenContract.approve(OPTIMISTIC_ORACLE_ADDRESS, CREATION_COST)
await tx.wait()

2. Create the Query

const optimisticOracle = new ethers.Contract(
  OPTIMISTIC_ORACLE_ADDRESS,
  OPTIMISTIC_ORACLE_ABI,
  signer
)

const question = "Will ETH price exceed $5000 by end of 2025?"
const options = ["Yes", "No"]

const tx = await optimisticOracle.createQuery(question, options)
const receipt = await tx.wait()

// Get query ID from event
const event = receipt.logs.find(log => log.eventName === 'OptimisticQueryCreated')
const queryId = event.args[0]
console.log('Created query ID:', queryId.toString())

Options Guidelines

Option Strings

  • Provide clear, unambiguous options
  • Each option must be non-empty
  • Minimum 2 options, maximum 254 options

Example Options

Good:

["Yes", "No"]
["Democrat", "Republican", "Other"]
["0-10%", "10-20%", "20-30%", "30%+"]

Bad:

["Yes"] // Only 1 option (need at least 2)
["Option A", ""] // Empty option not allowed

Cost Breakdown

30,000 $TRUTH creation cost is distributed as:

  • 20,000 tokens: Reward for correct proposer/challenger
  • 10,000 tokens: Returned to query creator

Using the UI

  1. Navigate to the Optimistic tab on the voting page
  2. Click Create Optimistic Query
  3. Enter your question
  4. Add options (minimum 2)
  5. Click Create Query
  6. Approve the transaction in your wallet

What Happens Next?

After creation, your query enters the Awaiting state, where:

  • Anyone can propose an answer
  • The first proposal starts the 1.5 hour dispute window
  • If undisputed, the proposal becomes the final answer

Best Practices

  1. Clear Questions: Make questions objective and verifiable
  2. Complete Options: Include all reasonable answers
  3. Timing: Consider when the answer will be known
  4. Incentives: Higher value questions attract more proposals