Skip to main content

Variables

NULL_ADDRESS

NULL_HASH

UNANSWERED

COMMITMENT_NON_EXISTENT

COMMITMENT_TIMEOUT_RATIO

BOND_CLAIM_FEE_PROPORTION

UNRESOLVED_ANSWER

Question

Commitment

Claim

nextTemplateID

templates

template_hashes

questions

question_claims

commitments

arbitrator_question_fees

reopened_questions

reopener_questions

Events

LogSetQuestionFee

LogNewTemplate

LogNewQuestion

LogMinimumBond

LogFundAnswerBounty

LogNewAnswer

LogAnswerReveal

LogNotifyOfArbitrationRequest

LogCancelArbitration

LogFinalize

LogClaim

LogReopenQuestion

Modifiers

onlyArbitrator

stateAny

stateNotCreated

stateOpen

statePendingArbitration

stateOpenOrPendingArbitration

stateFinalized

bondMustDoubleAndMatchMinimum

previousBondMustNotBeatMaxPrevious

Functions

constructor

Constructor, sets up some initial templates Creates some generalized templates for different question types used in the DApp.

setQuestionFee

Function for arbitrator to set an optional per-question fee. The per-question fee, charged when a question is asked, is intended as an anti-spam measure. Parameters

createTemplate

Create a reusable template, which should be a JSON document. Placeholders should use gettext() syntax, eg %s. Template data is only stored in the event logs, but its block number is kept in contract storage. Parameters Return Values

createTemplateAndAskQuestion

Create a new reusable template and use it to ask a question Template data is only stored in the event logs, but its block number is kept in contract storage. Parameters Return Values

askQuestion

Ask a new question and return the ID Template data is only stored in the event logs, but its block number is kept in contract storage. Parameters Return Values

askQuestionWithMinBond

Ask a new question and return the ID Template data is only stored in the event logs, but its block number is kept in contract storage. Parameters Return Values

_askQuestion

fundAnswerBounty

Add funds to the bounty for a question Add bounty funds after the initial question creation. Can be done any time until the question is finalized. Parameters

submitAnswer

Submit an answer for a question. Adds the answer to the history and updates the current “best” answer. May be subject to front-running attacks; Substitute submitAnswerCommitment()->submitAnswerReveal() to prevent them. Parameters

submitAnswerFor

Submit an answer for a question, crediting it to the specified account. Adds the answer to the history and updates the current “best” answer. May be subject to front-running attacks; Substitute submitAnswerCommitment()->submitAnswerReveal() to prevent them. Parameters

_storeCommitment

submitAnswerCommitment

Submit the hash of an answer, laying your claim to that answer if you reveal it in a subsequent transaction. Creates a hash, commitment_id, uniquely identifying this answer, to this question, with this bond. The commitment_id is stored in the answer history where the answer would normally go. Does not update the current best answer - this is left to the later submitAnswerReveal() transaction. Specifying the answerer is useful if you want to delegate the commit-and-reveal to a third-party. Parameters

submitAnswerReveal

Submit the answer whose hash you sent in a previous submitAnswerCommitment() transaction Checks the parameters supplied recreate an existing commitment, and stores the revealed answer Updates the current answer unless someone has since supplied a new answer with a higher bond msg.sender is intentionally not restricted to the user who originally sent the commitment; For example, the user may want to provide the answer+nonce to a third-party service and let them send the tx NB If we are pending arbitration, it will be up to the arbitrator to wait and see any outstanding reveal is sent Parameters

_addAnswerToHistory

_updateCurrentAnswer

_updateCurrentAnswerByArbitrator

notifyOfArbitrationRequest

Notify the contract that the arbitrator has been paid for a question, freezing it pending their decision. The arbitrator contract is trusted to only call this if they’ve been paid, and tell us who paid them. Parameters

cancelArbitration

Cancel a previously-requested arbitration and extend the timeout Useful when doing arbitration across chains that can’t be requested atomically Parameters

submitAnswerByArbitrator

Submit the answer for a question, for use by the arbitrator. Doesn’t require (or allow) a bond. If the current final answer is correct, the account should be whoever submitted it. If the current final answer is wrong, the account should be whoever paid for arbitration. However, the answerer stipulations are not enforced by the contract. Parameters

assignWinnerAndSubmitAnswerByArbitrator

Submit the answer for a question, for use by the arbitrator, working out the appropriate winner based on the last answer details. Doesn’t require (or allow) a bond. Parameters

isFinalized

Report whether the answer to the specified question is finalized Parameters Return Values

getFinalAnswer

(Deprecated) Return the final answer to the specified question, or revert if there isn’t one Parameters Return Values

resultFor

Return the final answer to the specified question, or revert if there isn’t one Parameters Return Values

isSettledTooSoon

Returns whether the question was answered before it had an answer, ie resolved to UNRESOLVED_ANSWER Parameters

resultForOnceSettled

Like resultFor(), but errors out if settled too soon, or returns the result of a replacement if it was reopened at the right time and settled Parameters

reopenQuestion

Asks a new question reopening a previously-asked question that was settled too soon A special version of askQuestion() that replaces a previous question that was settled too soon Parameters Return Values

getFinalAnswerIfMatches

Return the final answer to the specified question, provided it matches the specified criteria. Reverts if the question is not finalized, or if it does not match the specified criteria. Parameters Return Values

claimWinnings

Assigns the winnings (bounty and bonds) to everyone who gave the accepted answer Caller must provide the answer history, in reverse order Works up the chain and assign bonds to the person who gave the right answer If someone gave the winning answer earlier, they must get paid from the higher bond That means we can’t pay out the bond added at n until we have looked at n-1 The first answer is authenticated by checking against the stored history_hash. One of the inputs to history_hash is the history_hash before it, so we use that to authenticate the next entry, etc Once we get to a null hash we’ll know we’re done and there are no more answers. Usually you would call the whole thing in a single transaction, but if not then the data is persisted to pick up later. Parameters

_payPayee

_verifyHistoryInputOrRevert

_processHistoryItem

claimMultipleAndWithdrawBalance

Convenience function to assign bounties/bonds for multiple questions in one go, then withdraw all your funds. Caller must provide the answer history for each question, in reverse order Can be called by anyone to assign bonds/bounties, but funds are only withdrawn for the user making the call. Parameters

getContentHash

Returns the questions’s content hash, identifying the question content Parameters

getArbitrator

Returns the arbitrator address for the question Parameters

getOpeningTS

Returns the timestamp when the question can first be answered Parameters

getTimeout

Returns the timeout in seconds used after each answer Parameters

getFinalizeTS

Returns the timestamp at which the question will be/was finalized Parameters

isPendingArbitration

Returns whether the question is pending arbitration Parameters

getBounty

Returns the current total unclaimed bounty Set back to zero once the bounty has been claimed Parameters

getBestAnswer

Returns the current best answer Parameters

getHistoryHash

Returns the history hash of the question Updated on each answer, then rewound as each is claimed Parameters

getBond

Returns the highest bond posted so far for a question Parameters

getMinBond

Returns the minimum bond that can answer the question Parameters