Skip to main content
This guide is specific to Kleros V2: it uses the IArbitrableV2 and IArbitratorV2 interfaces and KlerosCore on Arbitrum. To build against Kleros V1 (ERC-792 and ERC-1497), see V1 Arbitrable Apps.

Interface Reference

Before building, understand the two interfaces your contract interacts with.

IArbitratorV2 (KlerosCore)

IArbitrableV2 (your contract)

extraData Encoding

extraData configures the court and juror count:
Tied votes: When votes are evenly split, currentRuling() returns tied = true and ruling = 0. The dispute remains in appeal until resolved. If never appealed after the period ends, ruling 0 (Refuse to Arbitrate) is executed. Always handle ruling 0 explicitly in your contract.

ERC-20 Fee Payment

On Arbitrum One, KlerosCore accepts ETH and accepted ERC-20 tokens (e.g. WETH):
ERC-20 fees only work when calling KlerosCore directly on Arbitrum. The ForeignGateway (for cross-chain disputes from Ethereum or Gnosis) only accepts native ETH.
To check accepted tokens, listen for the AcceptedFeeToken(token, accepted) event on KlerosCore.

Building an Escrow Contract

We’ll build a complete escrow that uses Kleros arbitration. This covers all the patterns you’ll need.

Contract Structure

Creating Transactions

Raising Disputes

Receiving Rulings

Dispute Templates

Templates tell jurors what they’re deciding. Two approaches: Store template on IPFS, reference by URI:
Upload to IPFS and use the URI in DisputeRequest.

Option B: On-Chain Template Registry

Register templates on-chain for dynamic disputes:

Data Mappings

For dynamic templates, use mappings to inject transaction data:

Evidence Submission

Emitting Evidence Events

Evidence JSON Format

Evidence is immutable once submitted. The fileURI should point to IPFS/Arweave for permanence.

Handling Appeals

Appeals are managed by the Dispute Kit, not your contract. However, you can track appeal status:

Fee Handling Patterns

Pattern: Loser Pays

Collect deposits from both parties, refund winner:

Pattern: Dynamic Fee Check

Always fetch current cost before creating dispute:

Extra Data Encoding

Configure court and juror count:

Complete Example

Next Steps

Testing Your Integration

Test scenarios and debugging strategies