RealityETH-3.0

Variables

NULL_ADDRESS

address NULL_ADDRESS

NULL_HASH

bytes32 NULL_HASH

UNANSWERED

uint32 UNANSWERED

COMMITMENT_NON_EXISTENT

uint256 COMMITMENT_NON_EXISTENT

COMMITMENT_TIMEOUT_RATIO

uint32 COMMITMENT_TIMEOUT_RATIO

BOND_CLAIM_FEE_PROPORTION

uint256 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

Name
Type
Description

fee

uint256

The fee to be charged by the arbitrator when a question is asked

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

Name
Type
Description

content

string

The template content

Return Values

Name
Type
Description

[0]

uint256

The ID of the newly-created template, which is created sequentially.

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

Name
Type
Description

content

string

The template content

question

string

A string containing the parameters that will be passed into the template to make the question

arbitrator

address

The arbitration contract that will have the final word on the answer if there is a dispute

timeout

uint32

How long the contract should wait after the answer is changed before finalizing on that answer

opening_ts

uint32

If set, the earliest time it should be possible to answer the question.

nonce

uint256

A user-specified nonce used in the question ID. Change it to repeat a question.

Return Values

Name
Type
Description

[0]

bytes32

The ID of the newly-created template, which is created sequentially.

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

Name
Type
Description

template_id

uint256

The ID number of the template the question will use

question

string

A string containing the parameters that will be passed into the template to make the question

arbitrator

address

The arbitration contract that will have the final word on the answer if there is a dispute

timeout

uint32

How long the contract should wait after the answer is changed before finalizing on that answer

opening_ts

uint32

If set, the earliest time it should be possible to answer the question.

nonce

uint256

A user-specified nonce used in the question ID. Change it to repeat a question.

Return Values

Name
Type
Description

[0]

bytes32

The ID of the newly-created question, created deterministically.

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

Name
Type
Description

template_id

uint256

The ID number of the template the question will use

question

string

A string containing the parameters that will be passed into the template to make the question

arbitrator

address

The arbitration contract that will have the final word on the answer if there is a dispute

timeout

uint32

How long the contract should wait after the answer is changed before finalizing on that answer

opening_ts

uint32

If set, the earliest time it should be possible to answer the question.

nonce

uint256

A user-specified nonce used in the question ID. Change it to repeat a question.

min_bond

uint256

The minimum bond that may be used for an answer.

Return Values

Name
Type
Description

[0]

bytes32

The ID of the newly-created question, created deterministically.

_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

Name
Type
Description

question_id

bytes32

The ID of the question you wish to fund

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

Name
Type
Description

question_id

bytes32

The ID of the question

answer

bytes32

The answer, encoded into bytes32

max_previous

uint256

If specified, reverts if a bond higher than this was submitted after you sent your transaction.

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

Name
Type
Description

question_id

bytes32

The ID of the question

answer

bytes32

The answer, encoded into bytes32

max_previous

uint256

If specified, reverts if a bond higher than this was submitted after you sent your transaction.

answerer

address

The account to which the answer should be credited

_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

Name
Type
Description

question_id

bytes32

The ID of the question

answer_hash

bytes32

The hash of your answer, plus a nonce that you will later reveal

max_previous

uint256

If specified, reverts if a bond higher than this was submitted after you sent your transaction.

_answerer

address

If specified, the address to be given as the question answerer. Defaults to the sender.

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

Name
Type
Description

question_id

bytes32

The ID of the question

answer

bytes32

The answer, encoded as bytes32

nonce

uint256

The nonce that, combined with the answer, recreates the answer_hash you gave in submitAnswerCommitment()

bond

uint256

The bond that you paid in your submitAnswerCommitment() transaction

_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

Name
Type
Description

question_id

bytes32

The ID of the question

requester

address

The account that requested arbitration

max_previous

uint256

If specified, reverts if a bond higher than this was submitted after you sent your transaction.

cancelArbitration

Cancel a previously-requested arbitration and extend the timeout

Useful when doing arbitration across chains that can't be requested atomically

Parameters

Name
Type
Description

question_id

bytes32

The ID of the question

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

Name
Type
Description

question_id

bytes32

The ID of the question

answer

bytes32

The answer, encoded into bytes32

answerer

address

The account credited with this answer for the purpose of bond claims

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

Name
Type
Description

question_id

bytes32

The ID of the question

answer

bytes32

The answer, encoded into bytes32

payee_if_wrong

address

The account to by credited as winner if the last answer given is wrong, usually the account that paid the arbitrator

last_history_hash

bytes32

The history hash before the final one

last_answer_or_commitment_id

bytes32

The last answer given, or the commitment ID if it was a commitment.

last_answerer

address

The address that supplied the last answer

isFinalized

Report whether the answer to the specified question is finalized

Parameters

Name
Type
Description

question_id

bytes32

The ID of the question

Return Values

Name
Type
Description

[0]

bool

Return true if finalized

getFinalAnswer

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

Parameters

Name
Type
Description

question_id

bytes32

The ID of the question

Return Values

Name
Type
Description

[0]

bytes32

The answer formatted as a bytes32

resultFor

Return the final answer to the specified question, or revert if there isn't one

Parameters

Name
Type
Description

question_id

bytes32

The ID of the question

Return Values

Name
Type
Description

[0]

bytes32

The answer formatted as a bytes32

isSettledTooSoon

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

Parameters

Name
Type
Description

question_id

bytes32

The ID of the question

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

Name
Type
Description

question_id

bytes32

The ID of the question

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

Name
Type
Description

template_id

uint256

The ID number of the template the question will use

question

string

A string containing the parameters that will be passed into the template to make the question

arbitrator

address

The arbitration contract that will have the final word on the answer if there is a dispute

timeout

uint32

How long the contract should wait after the answer is changed before finalizing on that answer

opening_ts

uint32

If set, the earliest time it should be possible to answer the question.

nonce

uint256

A user-specified nonce used in the question ID. Change it to repeat a question.

min_bond

uint256

The minimum bond that can be used to provide the first answer.

reopens_question_id

bytes32

The ID of the question this reopens

Return Values

Name
Type
Description

[0]

bytes32

The ID of the newly-created question, created deterministically.

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

Name
Type
Description

question_id

bytes32

The ID of the question

content_hash

bytes32

The hash of the question content (template ID + opening time + question parameter string)

arbitrator

address

The arbitrator chosen for the question (regardless of whether they are asked to arbitrate)

min_timeout

uint32

The timeout set in the initial question settings must be this high or higher

min_bond

uint256

The bond sent with the final answer must be this high or higher

Return Values

Name
Type
Description

[0]

bytes32

The answer formatted as a bytes32

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

Name
Type
Description

question_id

bytes32

The ID of the question

history_hashes

bytes32[]

Second-last-to-first, the hash of each history entry. (Final one should be empty).

addrs

address[]

Last-to-first, the address of each answerer or commitment sender

bonds

uint256[]

Last-to-first, the bond supplied with each answer or commitment

answers

bytes32[]

Last-to-first, each answer supplied, or commitment ID if the answer was supplied with commit->reveal

_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

Name
Type
Description

question_ids

bytes32[]

The IDs of the questions you want to claim for

lengths

uint256[]

The number of history entries you will supply for each question ID

hist_hashes

bytes32[]

In a single list for all supplied questions, the hash of each history entry.

addrs

address[]

In a single list for all supplied questions, the address of each answerer or commitment sender

bonds

uint256[]

In a single list for all supplied questions, the bond supplied with each answer or commitment

answers

bytes32[]

In a single list for all supplied questions, each answer supplied, or commitment ID

getContentHash

Returns the questions's content hash, identifying the question content

Parameters

Name
Type
Description

question_id

bytes32

The ID of the question

getArbitrator

Returns the arbitrator address for the question

Parameters

Name
Type
Description

question_id

bytes32

The ID of the question

getOpeningTS

Returns the timestamp when the question can first be answered

Parameters

Name
Type
Description

question_id

bytes32

The ID of the question

getTimeout

Returns the timeout in seconds used after each answer

Parameters

Name
Type
Description

question_id

bytes32

The ID of the question

getFinalizeTS

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

Parameters

Name
Type
Description

question_id

bytes32

The ID of the question

isPendingArbitration

Returns whether the question is pending arbitration

Parameters

Name
Type
Description

question_id

bytes32

The ID of the question

getBounty

Returns the current total unclaimed bounty

Set back to zero once the bounty has been claimed

Parameters

Name
Type
Description

question_id

bytes32

The ID of the question

getBestAnswer

Returns the current best answer

Parameters

Name
Type
Description

question_id

bytes32

The ID of the question

getHistoryHash

Returns the history hash of the question

Updated on each answer, then rewound as each is claimed

Parameters

Name
Type
Description

question_id

bytes32

The ID of the question

getBond

Returns the highest bond posted so far for a question

Parameters

Name
Type
Description

question_id

bytes32

The ID of the question

getMinBond

Returns the minimum bond that can answer the question

Parameters

Name
Type
Description

question_id

bytes32

The ID of the question

Last updated