Conventions
- Addresses are passed as strings (
asker_text,owner_text,reporter_text); the contract parses them and compares lower-case. - Amounts are integers in wei (1 GEN = 1018 wei). Large integers in view results may arrive as strings; wrap them in
BigInt(). - Times are Unix seconds, taken from the transaction timestamp.
- Expected failures revert with a message beginning
[EXPECTED]; internal invariant violations use[ERROR]. - Writes on Studionet need explicit fees. With genlayer-js use
estimateTransactionFeesForWrite()and passfeestowriteContract().
const fees = await client.estimateTransactionFeesForWrite({ address, functionName: "commit_answer", args, value: 0n });
const hash = await client.writeContract({ address, functionName: "commit_answer", args, value: 0n, fees });
const receipt = await client.waitForTransactionReceipt({ hash, status: "ACCEPTED" });
ERROR. Check the leader receipt, not only the status.Write methods
deposit_creditpayable
deposit_credit() → intAdds the attached GEN to your ledger credit and returns the new credit. This is the only way value enters the contract.
Reverts with Deposit must be positive
Send value > 0. Never send a zero deposit.
withdraw_creditwrite
withdraw_credit() → nullPull payment: transfers your entire available credit to your address in one transfer. Nobody else’s credit is touched.
Reverts with No available credit · Invalid transfer
Withdraw to an externally owned account.
open_questionwrite
open_question(question_id, question_text, reward_wei, stake_wei, min_reporters, max_reporters, commit_by, reveal_by) → stringOpens a question. Validators first run the suitability gate; only a clear verdict with confidence ≥ 70 passes. Then the reward moves from your credit into escrow. Returns the inferred answer shape (name, number, date, yes_no, phrase).
| Argument | Type | Notes |
|---|---|---|
question_id | string | 1–64 chars: letters, digits, _ . -, starting alphanumeric. Unique per asker. |
question_text | string | 10–400 characters. |
reward_wei | u256 | ≥ 1014 wei (0.0001 GEN). |
stake_wei | u256 | ≥ 1014 wei. Per reporter. |
min_reporters / max_reporters | u16 | 3 ≤ min ≤ max ≤ 12. |
commit_by | unix s | Commit deadline: ≥ 2 min and ≤ 30 days after the transaction time. |
reveal_by | unix s | Reveal deadline: ≥ 2 min and ≤ 7 days after commit_by. |
Reverts with Invalid question id · Duplicate question id · Reward below minimum · Stake below minimum · Invalid reporter limits · Invalid commit deadline · Invalid reveal deadline · Insufficient available credit · Question rejected as {verdict}: {note} · Question screening was inconclusive; rephrase it · Question screening failed; try again · Question screening is unavailable; try again
LLM call inside consensus. Allow a minute or two.
cancel_questionwrite
cancel_question(question_id) → nullAsker only. Cancels while nobody has committed and returns the reward to your credit.
| Argument | Type | Notes |
|---|---|---|
question_id | string | Your question id. |
Reverts with Question not found · Question cannot be cancelled
commit_answerwrite
commit_answer(asker_text, question_id, commitment_text) → intLocks the stake from your credit and records your SHA-256 commitment. Returns your report index.
| Argument | Type | Notes |
|---|---|---|
asker_text | string | Asker address. |
question_id | string | |
commitment_text | string | 0x + 64 hex characters. |
Reverts with Question not found · Question is not open · Committing is closed · Question is full · Asker cannot answer own question · Reporter already committed · Invalid SHA-256 · Insufficient available credit
Compute the commitment locally; see the Guide.
withdraw_commitwrite
withdraw_commit(asker_text, question_id) → nullBefore the commit deadline, withdraws your commitment and refunds the stake to your credit. Your slot stays used.
Reverts with No sealed answer to withdraw · Committing is closed
reveal_answerwrite
reveal_answer(asker_text, question_id, answer_text, salt_text) → nullReveals the answer. The contract recomputes the commitment and refuses mismatches.
| Argument | Type | Notes |
|---|---|---|
answer_text | string | 1–240 visible characters; whitespace is collapsed. |
salt_text | string | 16–64 chars from A-Za-z0-9_.~-. |
Reverts with Reveal window is not open · No sealed answer to reveal · Invalid salt · Reveal does not match the sealed commitment
Verify locally first to avoid wasting a fee.
adjudicate_questionwrite
adjudicate_question(asker_text, question_id) → nullAsker or a revealed reporter asks validators to group the revealed answers and flag instruction attempts. A strict majority settles the question; an inconclusive attempt is recorded and can be retried.
Reverts with Question is not open · Adjudication window is not open · Too few revealed answers; close the question · Only the asker or a revealed reporter may adjudicate · Adjudication cooldown is active · Adjudication budget exhausted
LLM call inside consensus. A failed or inconclusive attempt still consumes budget.
close_questionwrite
close_question(asker_text, question_id) → nullAnyone. Settles without a ruling once quorum is missing, the deadline has passed or the budget is spent. Honest reporters are refunded; the reward returns to the asker.
Reverts with Reveal window has not closed · Adjudication is still possible
View methods
get_infoview
get_info() → dictConstants, limits, rules and the list of AI roles.
get_accountingview
get_accounting() → dictCredits, locked rewards and stakes, liabilities, contract balance, unallocated, shortfall and solvent.
get_available_creditview
get_available_credit(owner_text) → intWithdrawable credit of an address (wei).
get_recordview
get_record(owner_text) → dictCounters and totals for an address as asker and reporter, plus majority_rate_bps.
get_question_countview
get_question_count() → intTotal number of questions.
list_questionsview
list_questions(offset, limit) → dictNewest first. Page size capped at 20. Returns total, offset, entries, has_more.
get_questionview
get_question(asker_text, question_id) → dictThe full question view.
get_question_bundleview
get_question_bundle(asker_text, question_id) → dictQuestion, every report and the grouped tally in one read — the whole question page.
get_reportview
get_report(asker_text, question_id, reporter_text) → dictOne reporter’s report.
get_reportersview
get_reporters(asker_text, question_id) → dictOrdered reporter addresses.
get_rulingview
get_ruling(asker_text, question_id) → dictThe oracle read: status, settlement, resolved, ruling, support, revealed, question.
Data model
Statuses
| Field | Values |
|---|---|
question.status | open · resolved · undecided · cancelled |
question.settlement | majority_ruling · no_majority · quorum_not_reached · adjudication_deadline_passed · adjudication_budget_exhausted · cancelled_before_any_commit |
report.status | committed · revealed · withdrawn |
report.outcome | in_majority · outvoted_stake_forfeited · excluded_instruction_attempt · unrevealed_stake_forfeited · refunded_no_ruling · withdrawn_stake_refunded |
question.reason | Last failed adjudication: inconclusive_assessment · consensus_execution_failure · invalid_consensus_result or a referee failure reason. |
Question view
question_id, asker, text, shape, gate_note, gate_confidence, reward_wei, stake_wei, min_reporters, max_reporters, report_count, revealed_count, created_at, commit_by, reveal_by, adjudicate_by, status, settlement, ruling, support, adjudication_calls, attempts, retry_at, confidence, rationale, reason, forfeited_wei, reward_returned_wei.
Report view
reporter, index, commitment, status, outcome, answer (empty until revealed), claim, group (0 = ungrouped), committed_at, revealed_at, stake_wei, payout_wei.
Revert reasons
All messages are prefixed [EXPECTED] and surface in the transaction receipt. This site extracts them and shows them in plain text.