### Example: Asking a Boolean Question Source: https://docs.kleros.io/integrations/types-of-integrations/3.-kleros-oracle-integration.md Example of how to call the askQuestion function to submit a boolean (Yes/No) question with a 0.1 ETH reward. ```solidity // Ask with a 0.1 ETH reward\nbytes32 questionID = realityETH.askQuestion{value: 0.1 ether}(\n 0, // Boolean template\n "Did the S&P 500 close above 5000 on April 16, 2025?␟finance␟en",\n arbitratorAddress,\n 86400, // 24 hour timeout\n 0, // Answerable immediately\n 0 // Default nonce\n); ``` -------------------------------- ### Query Documentation with GET Request Source: https://docs.kleros.io/contribution-guidelines/license-and-code-of-conduct/license.md Use this GET request to query the documentation dynamically. Include your question in the 'ask' parameter and an optional 'goal' parameter for tailored responses. ```http GET https://docs.kleros.io/contribution-guidelines/license-and-code-of-conduct/license.md?ask=&goal= ``` -------------------------------- ### Querying Documentation with GET Request Source: https://docs.kleros.io/integrations/types-of-integrations/1.-dispute-resolution-integration-plan/use-cases/1.-dispute-resolution-integration-plan/1.-dispute-resolution-integration-plan Use this GET request to dynamically query the documentation. Include an 'ask' parameter for your specific question and an optional 'goal' parameter to tailor the response. ```http GET https://docs.kleros.io/integrations/types-of-integrations/1.-dispute-resolution-integration-plan/use-cases/1.-dispute-resolution-integration-plan/1.-dispute-resolution-integration-plan.md?ask=&goal= ``` -------------------------------- ### Start Susie Bot Command Source: https://docs.kleros.io/products/retired/moderate/susie/getting-started/start-susie.md Use the /start command to initiate Susie's community moderation after she has been added as an admin. ```bash /start: Begins Susie's community moderation ``` -------------------------------- ### Query Documentation with GET Request Source: https://docs.kleros.io/developer/classic.md Use this GET request to query the documentation dynamically. Include your specific question in the 'ask' parameter and an optional broader goal in the 'goal' parameter for tailored responses. ```http GET https://docs.kleros.io/developer/classic.md?ask=&goal= ``` -------------------------------- ### Query Documentation with GET Request Source: https://docs.kleros.io/contribution-guidelines/general-dev.-workflow/releases.md To get information not explicitly on the current page, perform an HTTP GET request to the page URL with `ask` and optional `goal` query parameters. ```http GET https://docs.kleros.io/contribution-guidelines/general-dev.-workflow/releases.md?ask=&goal= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.kleros.io/products/escrow/new-in-progress-kleros-escrow-tutorial.md Use this GET request to ask questions about the documentation. Include your specific question in the 'ask' parameter and an optional broader goal in the 'goal' parameter. ```http GET https://docs.kleros.io/products/escrow/new-in-progress-kleros-escrow-tutorial.md?ask=&goal= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.kleros.io/developer/guide-for-preparing-transactions.md Use this GET request to ask questions about the documentation. Include your specific question in the 'ask' parameter and an optional broader goal in the 'goal' parameter. ```http GET https://docs.kleros.io/developer/guide-for-preparing-transactions.md?ask=&goal= ``` -------------------------------- ### Install Kleros GTCR SDK Source: https://docs.kleros.io/developer/classic.md Install the Kleros GTCR SDK using npm. This is the first step for integrating Kleros functionalities into your project. ```shell npm add @kleros/gtcr-sdk ``` -------------------------------- ### Query Deployment Addresses Documentation Source: https://docs.kleros.io/developer/deployment-addresses.md Perform an HTTP GET request to query the documentation dynamically. Use the 'ask' parameter for your specific question and optionally the 'goal' parameter to specify your broader objective. ```bash GET https://docs.kleros.io/developer/deployment-addresses.md?ask=&goal= ``` -------------------------------- ### Querying Documentation with Parameters Source: https://docs.kleros.io/contribution-guidelines/smart-contract-workflow.md Use this HTTP GET request to query the documentation dynamically. Include your specific question in the 'ask' parameter and an optional broader goal in the 'goal' parameter. ```HTTP GET https://docs.kleros.io/contribution-guidelines/smart-contract-workflow.md?ask=&goal= ``` -------------------------------- ### Query Documentation with Ask and Goal Parameters Source: https://docs.kleros.io/contribution-guidelines/general-dev.-workflow.md Use this HTTP GET request to query the documentation dynamically. The 'ask' parameter specifies the question, and the optional 'goal' parameter helps tailor the answer to a broader objective. ```HTTP GET https://docs.kleros.io/contribution-guidelines/general-dev.-workflow.md?ask=&goal= ``` -------------------------------- ### Query GitBook Documentation Source: https://docs.kleros.io/integrations/industry-use-cases.md Use this HTTP GET request to ask questions about the documentation. Include the 'ask' parameter for your specific question and optionally the 'goal' parameter for broader context. ```http GET https://docs.kleros.io/integrations/industry-use-cases.md?ask=&goal= ``` -------------------------------- ### Install file-to-ipfs Package Source: https://docs.kleros.io/developer/guide-for-preparing-transactions.md Install the file-to-ipfs package using yarn or npm. This package is used for pinning policy JSON files to IPFS. ```shell mkdir policy cd policy yarn init -y npm i @kleros/file-to-ipfs ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.kleros.io/integrations/types-of-integrations/1.-dispute-resolution-integration-plan/integration-tools.md Perform an HTTP GET request to query documentation dynamically. Use the `ask` parameter for specific questions and the optional `goal` parameter to tailor the answer. ```http GET https://docs.kleros.io/integrations/types-of-integrations/1.-dispute-resolution-integration-plan/integration-tools.md?ask=&goal= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.kleros.io/integrations/types-of-integrations/1.-dispute-resolution-integration-plan/use-cases/defi-insurance.md Perform an HTTP GET request to query the documentation dynamically. Use the `ask` parameter for specific questions and the optional `goal` parameter for broader context. ```HTTP GET https://docs.kleros.io/integrations/types-of-integrations/1.-dispute-resolution-integration-plan/use-cases/defi-insurance.md?ask=&goal= ``` -------------------------------- ### ERC-1497 Evidence Example for 'Yes' Answer Source: https://docs.kleros.io/integrations/types-of-integrations/3.-kleros-oracle-integration Provide a specific JSON example for evidence supporting a 'Yes' answer in a dispute, detailing the S&P 500 closing price. ```JSON { "fileURI": "/ipfs/QmScreenshotHash", "fileHash": "QmScreenshotHash", "name": "Evidence Supporting Yes", "description": "Proof that the S&P 500 closed above 5000 on April 16, 2025 - Official S&P website showing closing price of 5,127.43", "fileTypeExtension": "png" } ``` -------------------------------- ### MyArbitrable Contract Example Source: https://docs.kleros.io/developer/arbitration-development/arbitrable-proxy.md This snippet demonstrates how to interact with the ArbitrableProxy from your own contract. It includes creating a dispute and fetching its ruling. ```Solidity contract MyArbitrable { IArbitrableProxy arbitrableProxy = IArbitrableProxy(); function foo( bytes calldata extraData, string memory evidenceURI, uint256 rulingOptions ) { uint256 disputeID = arbitrableProxy.createDispute{value: msg.value}( extraData, evidenceURI, rulingOptions ); // do something with disputeID } function fetchRuling(uint256 disputeID) { (, bool isRuled, uint256 ruling) = arbitrableProxy.disputes(disputeID) // do something with ruling if isRuled } } ``` -------------------------------- ### ERC-1497 Evidence Example for 'No' Answer Source: https://docs.kleros.io/integrations/types-of-integrations/3.-kleros-oracle-integration Provide a specific JSON example for evidence supporting a 'No' answer in a dispute, detailing an alternative S&P 500 closing price. ```JSON { "fileURI": "/ipfs/QmCounterScreenshotHash", "fileHash": "QmCounterScreenshotHash", "name": "Evidence Supporting No", "description": "Proof that the S&P 500 did NOT close above 5000 on April 16, 2025 - Official S&P website showing closing price of 4,987.22", "fileTypeExtension": "png" } ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.kleros.io/developer/arbitration-by-example/rental.sol Perform an HTTP GET request to query documentation dynamically. Use the `ask` parameter for specific questions and the optional `goal` parameter for broader objectives. ```HTTP GET https://docs.kleros.io/developer/arbitration-by-example/rental.sol.md?ask=&goal= ``` -------------------------------- ### Query Documentation with GET Request Source: https://docs.kleros.io/products/proof-of-humanity/proof-of-humanity-tutorial.md Use this method to ask questions about the documentation when the answer is not explicitly present. The 'ask' parameter specifies the question, and the optional 'goal' parameter defines the broader objective. ```bash GET https://docs.kleros.io/products/proof-of-humanity/proof-of-humanity-tutorial.md?ask=&goal= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.kleros.io/developer/arbitration-development.md Use this GET request to query the documentation when information is not directly available on the page. The `ask` parameter is for your specific question, and `goal` is optional for tailoring the answer. ```http GET https://docs.kleros.io/developer/arbitration-development.md?ask=&goal= ``` -------------------------------- ### Querying GitBook Documentation Source: https://docs.kleros.io/developer/arbitration-by-example/arbitrabledeposit.sol Use this HTTP GET request to ask questions about the documentation. The `ask` parameter specifies the question, and the optional `goal` parameter provides context for the desired outcome. ```http GET https://docs.kleros.io/developer/arbitration-by-example/arbitrabledeposit.sol.md?ask=&goal= ``` -------------------------------- ### Query Documentation API Source: https://docs.kleros.io/developer/arbitration-by-example/multiplearbitrabletokentransaction.sol Demonstrates how to query documentation dynamically using an HTTP GET request with 'ask' and optional 'goal' parameters. This is useful for retrieving specific information not explicitly present on a page. ```HTTP GET https://docs.kleros.io/developer/arbitration-by-example/multiplearbitrabletokentransaction.sol.md?ask=&goal= ``` -------------------------------- ### Query Documentation Index via HTTP GET Source: https://docs.kleros.io/llms.txt Use this method to ask specific questions about the documentation. Include your question in the 'ask' parameter and optionally specify a broader 'goal' to tailor the response. The response will contain direct answers and relevant excerpts. ```http GET https://docs.kleros.io/kleros-faq.md?ask=&goal= ``` -------------------------------- ### Humanity Recovery Process Example Source: https://docs.kleros.io/products/proof-of-humanity/proof-of-humanity-2.0-integration-guide Illustrates the state transitions of a humanity ID during wallet recovery. This sequence shows the owner address changing while the humanity status is maintained. ```solidity // 1. Human loses access to wallet humanity.owner == lostAddress isHuman(lostAddress) == true // 2. Human requests removal of lost address humanity.owner == address(0) isHuman(lostAddress) == false // 3. Human registers with new wallet address humanity.owner == newAddress isHuman(newAddress) == true ``` -------------------------------- ### ERC-1497 Evidence Format Example Source: https://docs.kleros.io/integrations/types-of-integrations/3.-kleros-oracle-integration Structure your evidence according to the ERC-1497 standard, including file URI, hash, name, description, and file type. ```JSON { "fileURI": "/ipfs/QmScreenshotHash", "fileHash": "QmScreenshotHash", "name": "Evidence Supporting Yes", "description": "Official S&P website showing closing price of 5,127.43", "fileTypeExtension": "png" } ``` -------------------------------- ### Query Kleros Documentation Dynamically Source: https://docs.kleros.io/developer/arbitration-development/arbitrable-proxy.md Use this HTTP GET request to query the documentation. Include your specific question in the 'ask' parameter and an optional broader goal in the 'goal' parameter. ```http GET https://docs.kleros.io/developer/arbitration-development/arbitrable-proxy.md?ask=&goal= ``` -------------------------------- ### Query Kleros Escrow Documentation Source: https://docs.kleros.io/products/escrow/kleros-escrow-specifications.md Use this HTTP GET request to dynamically query the documentation. Include your specific question in the 'ask' parameter and an optional broader goal in the 'goal' parameter. ```HTTP GET https://docs.kleros.io/products/escrow/kleros-escrow-specifications.md?ask=&goal= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.kleros.io/contribution-guidelines/code-style-and-guidelines/solidity.md Use this method to ask questions about the documentation when information is not explicitly present on the current page. The `ask` parameter is mandatory for specifying the question, and the `goal` parameter is optional for tailoring the answer. ```HTTP GET https://docs.kleros.io/contribution-guidelines/code-style-and-guidelines/solidity.md?ask=&goal= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.kleros.io/integrations/types-of-integrations/1.-dispute-resolution-integration-plan/smart-contract-integration.md Use this GET request to query the documentation dynamically with a specific question and an optional end goal. This is useful when the answer is not explicitly present on the page or when additional context is needed. ```http GET https://docs.kleros.io/integrations/types-of-integrations/1.-dispute-resolution-integration-plan/smart-contract-integration.md?ask=&goal= ``` -------------------------------- ### Example Branch Names Source: https://docs.kleros.io/contribution-guidelines/code-style-and-guidelines/git.md Use short, descriptive, kebab-cased branch names with a Conventional Commits type prefix. Personal branches can be created by appending a name after a slash. ```git feat/implement-arbitrator ``` ```git fix/invalid-rulings-from-arbitrator ``` ```git feat/implement-arbitrator/alice ``` ```git feat/implement-arbitrator/bob ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.kleros.io/integrations/types-of-integrations.md Perform an HTTP GET request to query documentation dynamically. Use the `ask` parameter for your question and optionally the `goal` parameter for broader context. This is useful when information is not explicitly present on the current page. ```http GET https://docs.kleros.io/integrations/types-of-integrations.md?ask=&goal= ``` -------------------------------- ### Provide Explicit Examples of Non-Duplicates Source: https://docs.kleros.io/integrations/policy-writing-guide.md Illustrate what constitutes independent submissions and should not be considered duplicates, especially when dealing with similar tags across different networks or versions. ```text Submissions on either chain must be considered independently and on their own merits. To be explicit, each pair of submissions in the following two examples must not be considered duplicates: * Tagging 0xdc6…3A35 as “Curve.fi: EURS/sEUR” on ETH Mainnet and in Gnosis. * Tagging 0xdc6…3A35 as “Curve.fi: EURS/sEUR v2” on ETH Mainnet and “Curve.fi: EURS/sEUR (v2)” on Gnosis. ``` -------------------------------- ### Querying Kleros Documentation Source: https://docs.kleros.io/integrations/types-of-integrations/1.-dispute-resolution-integration-plan/channel-partners/kleros-reality-module.md Use this HTTP GET request to ask specific questions about the documentation or to retrieve broader context for a particular goal. The 'ask' parameter is mandatory for specifying the question. ```http GET https://docs.kleros.io/integrations/types-of-integrations/1.-dispute-resolution-integration-plan/channel-partners/kleros-reality-module.md?ask=&goal= ``` -------------------------------- ### Query Kleros FAQ Documentation Source: https://docs.kleros.io/kleros-faq.md Use this GET request to query the Kleros FAQ dynamically with specific questions and optional goals. The response includes direct answers and relevant documentation excerpts. ```http GET https://docs.kleros.io/kleros-faq.md?ask=&goal= ``` -------------------------------- ### Query Kleros Documentation Source: https://docs.kleros.io/pnk-token.md Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections. Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter. ```http GET https://docs.kleros.io/pnk-token.md?ask=&goal= ``` -------------------------------- ### Get Transaction Count Source: https://docs.kleros.io/developer/arbitration-by-example/multiplearbitrabletokentransaction.sol.md A public view function to retrieve the total number of transactions recorded in the contract. ```Solidity /** @dev Getter to know the count of transactions. * @return countTransactions The count of transactions. */ function getCountTransactions() public view returns (uint countTransactions) { return transactions.length; } ``` -------------------------------- ### Example Arbitrator Interface URL with Query String Source: https://docs.kleros.io/developer/arbitration-development/erc-1497-evidence-standard.md This URL is used by the iframe on the Arbitrator interface to load case details. It includes parameters like disputeID, chainID, and arbitrator contract information. ```typescript // URL decoded example for readability https://cdn.kleros.link/ipfs/QmSL8d82dMhcThwERWaF4LtmCa4hgV7TyPjAo4fKCzPVkv/index.html?{"disputeID":"1500","chainID":1,"arbitratorContractAddress":"0x988b3a538b618c7a603e1c11ab82cd16dbe28069","arbitratorJsonRpcUrl":"https://rpc.eth.gateway.fm","arbitratorChainID":1,"arbitrableContractAddress":"0xC5E9dDebb09Cd64DfaCab4011A0D5cEDaf7c9BDb","arbitrableChainID":1,"arbitrableJsonRpcUrl":"https://rpc.eth.gateway.fm","jsonRpcUrl":"https://rpc.eth.gateway.fm"} ``` -------------------------------- ### Update RAB Pragma Comment Source: https://docs.kleros.io/contribution-guidelines/smart-contract-workflow/rabd.md This example shows how to update the contract's RAB pragma comment with the latest commit hash and the soon-to-be contract address. This is a crucial step in the deployment process to maintain a record of deployed versions. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract MyContract { // Contract code here // Example deployment entry: // 90ed3a5e944d7e7c5d413366ad9f0c530cd92880@0xb7faddf3ecd2402a7e48cea6d2637d90eeb5a7e6 } ``` -------------------------------- ### Fetch Meta Evidence and Metadata Source: https://docs.kleros.io/developer/classic.md Retrieve the latest meta evidence files for both registration and removal from a GTCR. This data includes crucial UI information like the list's title, description, logo, and column definitions. The metadata structure is detailed in the example. ```typescript const gtcr = new GeneralizedTCR( window.ethereum, LIST_ADDRESS, GTCR_VIEW_ADDRESS, IPFS_GATEWAY, DEPLOYMENT_BLOCK ); const [registrationMetaEvidence, removalMetaEvidence] = (await gtcr.getLatestMetaEvidence()) // Both removal and registration meta evidence contain the same `metadata`. console.info(registrationMetaEvidence.metadata) // Outputs { tcrTitle: string // The list title. tcrDescription: string // The list description. columns: Column[] // Used by @kleros/gtcr-encoder itemName: string // The noun used when building UIs. E.g. "Token" for a list of tokens -> generates "Submit *token*", "Challenge token", etc. itemNamePlural: string // Plural version of `itemName`. logoURI: string // Link to the list logo. Usually an IPFS URI. requireRemovalEvidence: boolean // Whether to require evidence when removing an item. isTCRofTCRs: boolean // Whether this is a list of GTCR addresses. relTcrDisabled: boolean // Whether the badges TCR is enabled. } ``` -------------------------------- ### SmartContract.sol RAB Pragmas Source: https://docs.kleros.io/contribution-guidelines/smart-contract-workflow/rab.md This comment block should be placed at the start of each file undergoing the RAB process. It includes fields for authors, reviewers, auditors, bounties, and deployments, with a note on handling stale entries using asterisks. ```javascript /** * @authors: * @reviewers: * @auditors: * @bounties: * @deployments: (// For RABd) */ @pragma... ``` -------------------------------- ### MetaEvidence JSON Structure Example Source: https://docs.kleros.io/developer/arbitration-development/erc-1497-evidence-standard.md This JSON object represents a typical MetaEvidence structure used in Kleros disputes. It includes details about the dispute category, title, description, ruling options, file URI, and an interface for displaying evidence. ```json { "category": "Insurance", "title": "Unslashed insurance claim", "description": "The claimant requested a compensation for damages covered by Unslashed insurance in the provided amount.", "question": "Should their claim be paid out?", "rulingOptions": { "type": "single-select", "titles": [ "Accept the claim", "Reject the claim" ], "descriptions": [ "Accept the claim if the claimant 1) incurred the alleged damages, 2) is covered by a relevant policy, 3) the damages and their cover are at least the claimed amount at the moment when the claim was filled.", "Reject the claim if any of the acceptance criteria do not hold." ] }, "fileURI": "/ipfs/QmeTBY7jZe2ut5WjifNASADo3E4zBxkMd62WwBpXtwP9pg", "evidenceDisplayInterfaceURI": "https://app.unslashed.finance/embed/claims" } ``` -------------------------------- ### TCR Item Submission Example Source: https://docs.kleros.io/developer/light-curate.md Submits an item to a TCR contract after preparing its metadata and values. This involves encoding the item data, publishing it to IPFS, and then calling the TCR's addItem function. ```typescript const gtcr = new ethers.Contract(tcrAddress, _gtcr, signer) const enc = new TextEncoder() const fileData = enc.encode(JSON.stringify({ columns, values })) const ipfsEvidencePath = await ipfsPublish('item.json', fileData) // Request signature and submit. const tx = await gtcr.addItem(ipfsEvidencePath, { value: submissionDeposit }) ``` -------------------------------- ### Retrieve Answer from Reality.eth Source: https://docs.kleros.io/integrations/types-of-integrations/3.-kleros-oracle-integration Use the resultFor function to get the finalized answer for a given question ID. This function will revert if the question is not yet finalized. Use isQuestionFinalized for a safe check. ```solidity function getAnswer(bytes32 questionID) external view returns (bytes32) { // This will revert if the question is not finalized return realityETH.resultFor(questionID); } ``` ```solidity // For safer access that won't revert: function isQuestionFinalized(bytes32 questionID) external view returns (bool) { try realityETH.resultFor(questionID) returns (bytes32) { return true; } catch { return false; } } ``` -------------------------------- ### Get Transaction Count Source: https://docs.kleros.io/developer/arbitration-by-example/multiplearbitrabletokentransaction.sol Retrieves the total number of transactions recorded in the contract. ```APIDOC ## GET /getCountTransactions ### Description Returns the total count of transactions managed by the contract. ### Method GET ### Endpoint `/getCountTransactions` ### Parameters #### Path Parameters None #### Query Parameters None ### Response #### Success Response (200) - **countTransactions** (uint) - The total number of transactions. #### Response Example ```json { "countTransactions": 10 } ``` ``` -------------------------------- ### Get Transaction Count Source: https://docs.kleros.io/developer/arbitration-by-example/multiplearbitrabletransaction.sol.md Returns the total number of arbitrable transactions currently managed by the contract. ```Solidity /** @dev Getter to know the count of transactions. * @return countTransactions The count of transactions. */ function getCountTransactions() public view returns (uint countTransactions) { return transactions.length; } ``` -------------------------------- ### Get transaction count in MultipleArbitrableTransaction.sol Source: https://docs.kleros.io/developer/arbitration-by-example/multiplearbitrabletransaction.sol Returns the total number of arbitrable transactions managed by the contract. ```Solidity function getCountTransactions() public view returns (uint countTransactions) { return transactions.length; } ``` -------------------------------- ### Get Arbitration Cost Source: https://docs.kleros.io/products/escrow/kleros-escrow-specifications.md Obtain the required arbitration cost in wei by calling this function on the arbitrator contract. Pass the same extra data used in the constructor. ```solidity arbitrationCost(_extraData) ``` -------------------------------- ### Querying Documentation Source: https://docs.kleros.io/developer/arbitration-by-example/arbitrabletransaction.sol.md You can query this documentation dynamically by asking a question using the `ask` query parameter. An optional `goal` parameter can be used to tailor the answer. ```http GET https://docs.kleros.io/developer/arbitration-by-example/arbitrabletransaction.sol.md?ask=&goal= ``` -------------------------------- ### Get Transaction IDs by Address Source: https://docs.kleros.io/developer/arbitration-by-example/multiplearbitrabletransaction.sol.md Retrieves all transaction IDs where a given address is either the sender or the receiver. This function is intended for UI use and has a time complexity of O(t). ```Solidity /** @dev Get IDs for transactions where the specified address is the receiver and/or the sender. * This function must be used by the UI and not by other smart contracts. * Note that the complexity is O(t), where t is amount of arbitrable transactions. * @param _address The specified address. * @return transactionIDs The transaction IDs. */ function getTransactionIDsByAddress(address _address) public view returns (uint[] transactionIDs) { uint count = 0; for (uint i = 0; i < transactions.length; i++) { if (transactions[i].sender == _address || transactions[i].receiver == _address) count++; } transactionIDs = new uint[](count); count = 0; for (uint j = 0; j < transactions.length; j++) { if (transactions[j].sender == _address || transactions[j].receiver == _address) transactionIDs[count++] = j; } } ``` -------------------------------- ### Get transaction IDs by address in MultipleArbitrableTransaction.sol Source: https://docs.kleros.io/developer/arbitration-by-example/multiplearbitrabletransaction.sol Retrieves all transaction IDs where a given address is either the sender or receiver. This function is intended for UI use and has a time complexity of O(t). ```Solidity function getTransactionIDsByAddress(address _address) public view returns (uint[] transactionIDs) { uint count = 0; for (uint i = 0; i < transactions.length; i++) { if (transactions[i].sender == _address || transactions[i].receiver == _address) count++; } transactionIDs = new uint[](count); count = 0; for (uint j = 0; j < transactions.length; j++) { if (transactions[j].sender == _address || transactions[j].receiver == _address) transactionIDs[count++] = j; } } ``` -------------------------------- ### Configure DApp with Reality.eth Interface Source: https://docs.kleros.io/integrations/types-of-integrations/3.-kleros-oracle-integration Import the IRealityETH interface and initialize it in your DApp's constructor. Ensure you use the correct contract address for your network. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IRealityETH.sol"; contract MyDApp { IRealityETH public realityETH; constructor(address _realityETHAddress) { realityETH = IRealityETH(_realityETHAddress); } // The rest of your contract... } ``` -------------------------------- ### Query Documentation with Ask Parameter Source: https://docs.kleros.io/contribution-guidelines Use this mechanism to query the documentation dynamically when the answer is not explicitly present on the page, or when clarification or additional context is needed. The `ask` parameter is for the immediate question, and the optional `goal` parameter helps tailor the answer. ```HTTP GET https://docs.kleros.io/contribution-guidelines.md?ask=&goal= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.kleros.io/readme.md Use this method to ask questions about the documentation when the answer is not explicitly present on the current page. The `ask` parameter is mandatory for specifying the question, while `goal` is optional for providing broader context. ```HTTP GET https://docs.kleros.io/readme.md?ask=&goal= ``` -------------------------------- ### Rental Contract Initialization Source: https://docs.kleros.io/developer/arbitration-by-example/rental.sol Initializes the rental contract with arbitrator details, timeout, party B (owner), and meta-evidence. The constructor also accepts payment, adding it to the contract's balance. ```Solidity constructor( Arbitrator _arbitrator, uint _timeout, address _partyB, bytes _arbitratorExtraData, string _metaEvidence ) public TwoPartyArbitrable(_arbitrator,_timeout,_partyB,AMOUNT_OF_CHOICES,_arbitratorExtraData, _metaEvidence) payable { amount += msg.value; } ``` -------------------------------- ### Import Reality.eth Interface Source: https://docs.kleros.io/integrations/types-of-integrations/3.-kleros-oracle-integration.md Import the IRealityETH interface into your Solidity contract to interact with the Reality.eth oracle. ```solidity // SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport "./IRealityETH.sol";\n\ncontract MyDApp {\n IRealityETH public realityETH;\n \n constructor(address _realityETHAddress) {\n realityETH = IRealityETH(_realityETHAddress);\n }\n \n // The rest of your contract...\n} ``` -------------------------------- ### Configure IPFS Endpoints for Light Curate Source: https://docs.kleros.io/developer/light-curate.md Set environment variables to configure the IPFS gateway and the hosted Graph IPFS endpoint. These are necessary for item submission when using `@graphprotocol/graph-ts`. ```bash REACT_APP_IPFS_GATEWAY=https://cdn.kleros.link REACT_APP_HOSTED_GRAPH_IPFS_ENDPOINT=https://api.thegraph.com/ipfs ``` -------------------------------- ### Query Linguo Documentation Source: https://docs.kleros.io/products/retired/linguo/high-level-overview.md Use this endpoint to ask questions about the Linguo documentation. Include your specific question in the 'ask' parameter and an optional broader goal in the 'goal' parameter. ```http GET https://docs.kleros.io/products/retired/linguo/high-level-overview.md?ask=&goal= ``` -------------------------------- ### Create a Transaction Source: https://docs.kleros.io/developer/arbitration-by-example/multiplearbitrabletransaction.sol.md Use this function to initiate a new transaction. It requires a payment timeout, the receiver's address, and a link to meta-evidence. The transaction is created with an initial status of 'NoDispute'. ```Solidity function createTransaction( uint _timeoutPayment, address _receiver, string _metaEvidence ) public payable returns (uint transactionID) { transactions.push(Transaction({ sender: msg.sender, receiver: _receiver, amount: msg.value, timeoutPayment: _timeoutPayment, disputeId: 0, senderFee: 0, receiverFee: 0, lastInteraction: now, status: Status.NoDispute })); emit MetaEvidence(transactions.length - 1, _metaEvidence); emit TransactionCreated(transactions.length - 1, msg.sender, _receiver, msg.value); return transactions.length - 1; } ``` -------------------------------- ### Ask a Question to Reality.eth Source: https://docs.kleros.io/integrations/types-of-integrations/3.-kleros-oracle-integration Submit a question to Reality.eth using the askQuestion function. Specify the template, question text, arbitrator, timeouts, and reward. The ETH sent with the transaction becomes the question reward. ```solidity function askQuestion( uint256 templateID, string calldata question, address arbitrator, uint32 timeout, uint32 openingTimestamp, uint256 nonce ) external payable returns (bytes32 questionID) { // Choose the appropriate Kleros arbitrator proxy address for your network address arbitrator = 0xFf32eff53459485074b4Db14633252C9dcA3791A;// Example: Mainnet General Court // Any ETH sent with this transaction becomes the question reward return realityETH.askQuestion{value: msg.value}( templateID, question, arbitrator, timeout, openingTimestamp, nonce ); } ``` ```solidity // Ask with a 0.1 ETH reward bytes32 questionID = realityETH.askQuestion{value: 0.1 ether}( 0, // Boolean template "Did the S&P 500 close above 5000 on April 16, 2025?␟finance␟en", arbitratorAddress, 86400, // 24 hour timeout 0, // Answerable immediately 0 // Default nonce ); ``` -------------------------------- ### Solidity DApp Contract for Evidence Submission Source: https://docs.kleros.io/integrations/types-of-integrations/3.-kleros-oracle-integration.md A sample DApp contract demonstrating how to integrate with the Kleros Arbitrator Proxy to submit evidence for a given question ID. It requires the address of the arbitrator proxy during deployment. ```solidity import { IKlerosArbitratorProxy } from "./IKlerosArbitratorProxy"; // Assuming interface is in a separate file contract MyDApp { IKlerosArbitratorProxy public arbitratorProxy; constructor(address _arbitratorProxyAddress) { arbitratorProxy = IKlerosArbitratorProxy(_arbitratorProxyAddress); } function submitEvidenceForQuestion( bytes32 questionID, string calldata evidenceURI ) external { // Convert questionID to uint256 for the arbitrator proxy uint256 questionIDUint = uint256(questionID); arbitratorProxy.submitEvidence(questionIDUint, evidenceURI); } } ``` -------------------------------- ### Submit Evidence via Smart Contract Integration Source: https://docs.kleros.io/integrations/types-of-integrations/3.-kleros-oracle-integration Integrate Kleros Arbitrator Proxy functionality into your DApp to allow users to submit evidence for Reality.eth disputes. ```Solidity // Import the arbitrator proxy interface interface IKlerosArbitratorProxy { function submitEvidence( uint256 _questionID, string calldata _evidenceURI ) external; } contract MyDApp { IKlerosArbitratorProxy public arbitratorProxy; constructor(address _arbitratorProxyAddress) { arbitratorProxy = IKlerosArbitratorProxy(_arbitratorProxyAddress); } function submitEvidenceForQuestion( bytes32 questionID, string calldata evidenceURI ) external { // Convert questionID to uint256 for the arbitrator proxy uint256 questionIDUint = uint256(questionID); arbitratorProxy.submitEvidence(questionIDUint, evidenceURI); } } ``` -------------------------------- ### Proof of Humanity Vouching Interface Source: https://docs.kleros.io/products/proof-of-humanity/proof-of-humanity-2.0-integration-guide Provides functions for managing vouches, including adding, removing, and checking the status of vouches. Supports advanced vouching with signature verification. ```solidity interface IProofOfHumanityVouching { struct SignatureVouch { uint40 expirationTime; // Time when the signature expires uint8 v; // 'v' value of the signature bytes32 r; // 'r' value of the signature bytes32 s; // 's' value of the signature } // Basic vouching functions function addVouch(address _account, bytes20 _humanityId) external; function removeVouch(address _account, bytes20 _humanityId) external; function vouches(address _voucher, address _claimer, bytes20 _humanityId) external view returns (bool); // Advanced vouching with signature support function advanceState( address _claimer, address[] calldata _vouches, SignatureVouch[] calldata _signatureVouches ) external; } ``` -------------------------------- ### Ask a Question Source: https://docs.kleros.io/integrations/types-of-integrations/3.-kleros-oracle-integration Submit a question to Reality.eth. The function takes various parameters to define the question format, content, arbitration, and timing. Any ETH sent with this transaction becomes the question reward. ```APIDOC ## askQuestion ### Description Submits a question to the Reality.eth protocol. This function allows users to define the question's format, content, the arbitrator for disputes, and timing parameters. The transaction's value is used as the reward for the question. ### Method `askQuestion` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Payable Yes, any ETH sent with this transaction becomes the question reward. #### Parameters - **templateID** (uint256) - Required - The question format template. Common values: 0 (Boolean), 1 (Numerical), 2 (Single-select), 3 (Multi-select), 4 (Datetime), 5 (Hash). - **question** (string calldata) - Required - The actual question string, formatted according to the templateID and delimited by '␟'. - **arbitrator** (address) - Required - The address of the Kleros Arbitrator Proxy that will handle disputes. - **timeout** (uint32) - Required - Time in seconds for answer finalization after receiving an answer. Max 365 days (31,536,000 seconds). - **openingTimestamp** (uint32) - Required - Unix timestamp for the earliest answer submission time. Set to 0 for immediate answerability. - **nonce** (uint256) - Required - A user-supplied number to differentiate identical questions with identical parameters. ### Request Example ```solidity // Ask with a 0.1 ETH reward bytes32 questionID = realityETH.askQuestion{value: 0.1 ether}( 0, // Boolean template "Did the S&P 500 close above 5000 on April 16, 2025?␟finance␟en", arbitratorAddress, // e.g., 0xFf32eff53459485074b4Db14633252C9dcA3791A 86400, // 24 hour timeout 0, // Answerable immediately 0 // Default nonce ); ``` ### Response #### Success Response - **questionID** (bytes32) - The unique identifier for the submitted question. ``` -------------------------------- ### Import IArbitrableProxy Interface Source: https://docs.kleros.io/developer/arbitration-development/arbitrable-proxy.md Import the IArbitrableProxy interface to interact with the proxy contract. This interface defines the necessary functions for managing disputes. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@kleros/erc-792/contracts/IArbitrator.sol"; /** * @title IArbitrableProxy * A general purpose arbitrable contract. Supports non-binary rulings. */ interface IArbitrableProxy { function arbitrator() external view returns (IArbitrator arbitrator); function createDispute( bytes calldata _arbitratorExtraData, string calldata _metaevidenceURI, uint256 _numberOfRulingOptions ) external payable returns (uint256 disputeID); struct DisputeStruct { bytes arbitratorExtraData; bool isRuled; uint256 ruling; uint256 disputeIDOnArbitratorSide; } function externalIDtoLocalID( uint256 _externalID ) external returns (uint256 localID); function disputes( uint256 _localID ) external returns ( bytes memory extraData, bool isRuled, uint256 ruling, uint256 disputeIDOnArbitratorSide ); function submitEvidence(uint256 _localDisputeID, string calldata _evidenceURI) external; } ``` -------------------------------- ### Interactive Staging Source: https://docs.kleros.io/contribution-guidelines/code-style-and-guidelines/git.md Use `git add -p` to interactively stage specific portions of modified files, allowing for more granular commits. ```git git add -p ``` -------------------------------- ### Instantiate ArbitrableProxy Contract Source: https://docs.kleros.io/developer/arbitration-development/arbitrable-proxy.md Instantiate the IArbitrableProxy contract by providing the address of the arbitrator. This allows your contract to call functions on the proxy. ```solidity contract MyArbitrable { IArbitrableProxy arbitrableProxy = IArbitrableProxy(); } ``` -------------------------------- ### Pin Policy Files to IPFS Source: https://docs.kleros.io/developer/guide-for-preparing-transactions.md Use the file-to-ipfs package to pin policy JSON files to IPFS. This script handles pinning Solidity, Javascript, and Development court policies. ```javascript const ftIpfs = require("@kleros/file-to-ipfs"); async function pinSol() { const solPath = await ftIpfs("./files/xDai-Solidity-Court-Policy.json"); console.log(`Solidity Court: ${solPath}`); } async function pinJs() { const jsPath = await ftIpfs("./files/xDai-Javascript-Court-Policy.json"); console.log(`Javascript Court: ${jsPath}`); } async function pinDev() { const devPath = await ftIpfs("./files/xDai-Development-Court-Policy.json"); console.log(`Development Court: ${devPath}`); } async function main() { pinSol(); pinJs(); pinDev(); } main(); /* Output Development Court: /ipfs/QmbgUL2iv9XH3jui7xdLBXp2Hqe4VqGnNkK7PnAorJ8XQa/xDai-Development-Court-Policy.json Solidity Court: /ipfs/QmQbyk1qnD4e4MQrwSr6a21w2t82YJEMxU3F7QTYKkxuNS/xDai-Solidity-Court-Policy.json Javascript Court: /ipfs/Qme15AUfpvLX3iwEtqswe26PQHMmKnF4eWGywBPqbkdqcD/xDai-Javascript-Court-Policy.json */ ``` -------------------------------- ### IEvidence Interface Definition Source: https://docs.kleros.io/developer/arbitration-development/erc-1497-evidence-standard.md Defines the interface for submitting meta-evidence and evidence, and for linking disputes to meta-evidence. Evidence paths are expected to be IPFS URIs. ```solidity // SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport "../IArbitrator.sol";\n\n/** @title IEvidence\n * ERC-1497: Evidence Standard\n */\ninterface IEvidence {\n /**\n * @dev To be emitted when meta-evidence is submitted.\n * @param _metaEvidenceID Unique identifier of meta-evidence.\n * @param _evidence IPFS path to metaevidence, example: '/ipfs/QmbsNh1pDfqKmaySamNCnEoWQpd8E7RfpBrF3HPZS7xKVK'\n */\n event MetaEvidence(uint256 indexed _metaEvidenceID, string _evidence);\n\n /**\n * @dev To be raised when evidence is submitted. Should point to the resource (evidences are not to be stored on chain due to gas considerations).\n * @param _arbitrator The arbitrator of the contract.\n * @param _evidenceGroupID Unique identifier of the evidence group the evidence belongs to.\n * @param _party The address of the party submiting the evidence. Note that 0x0 refers to evidence not submitted by any party.\n * @param _evidence IPFS path to evidence, example: '/ipfs/Qmarwkf7C9RuzDEJNnarT3WZ7kem5bk8DZAzx78acJjMFH/evidence.json'\n */\n event Evidence(\n IArbitrator indexed _arbitrator,\n uint256 indexed _evidenceGroupID,\n address indexed _party,\n string _evidence\n );\n\n /**\n * @dev To be emitted when a dispute is created to link the correct meta-evidence to the disputeID.\n * @param _arbitrator The arbitrator of the contract.\n * @param _disputeID ID of the dispute in the Arbitrator contract.\n * @param _metaEvidenceID Unique identifier of meta-evidence.\n * @param _evidenceGroupID Unique identifier of the evidence group that is linked to this dispute.\n */\n event Dispute(\n IArbitrator indexed _arbitrator,\n uint256 indexed _disputeID,\n uint256 _metaEvidenceID,\n uint256 _evidenceGroupID\n );\n}\n ``` -------------------------------- ### Conventional Commits with Yarn Source: https://docs.kleros.io/contribution-guidelines/code-style-and-guidelines/git.md If the repository uses Kathari, you can use `yarn run cz` to craft valid Conventional Commit messages by following the prompts. ```bash yarn run cz ``` -------------------------------- ### Manual SafeSnap Configuration Parameters Source: https://docs.kleros.io/integrations/types-of-integrations/1.-dispute-resolution-integration-plan/channel-partners/kleros-reality-module.md When configuring SafeSnap manually, specify the network ID and the Reality Module address. Quotes are required around the network ID. ```JSON { "safes": [ { "network": "1", "realityAddress": "0x0811dE7b6CA6fF61C24eB8C6C885F44d1Bca4c28" } ] } ``` -------------------------------- ### Monitor Dispute and Evidence Events Source: https://docs.kleros.io/integrations/types-of-integrations/3.-kleros-oracle-integration Listen for Dispute and Evidence events emitted by the arbitrator proxy contract to track dispute creation and evidence submissions. ```Solidity // Listen for Dispute events from the arbitrator proxy event Dispute( IArbitrator indexed _arbitrator, uint256 indexed _disputeID, uint256 _metaEvidenceID, uint256 _evidenceGroupID ); // Listen for Evidence events to see what others have submitted event Evidence( IArbitrator indexed _arbitrator, uint256 indexed _evidenceGroupID, address indexed _party, string _evidence ); ``` -------------------------------- ### Built-in Reality.eth + Kleros Oracle Templates Source: https://docs.kleros.io/integrations/types-of-integrations/3.-kleros-oracle-integration These are the predefined JSON templates used for creating questions in the Reality.eth + Kleros oracle system. They define the structure and type of expected answers. ```json 0: {"title": "%s", "type": "bool", "category": "%s", "lang": "%s"} 1: {"title": "%s", "type": "uint", "decimals": 18, "category": "%s", "lang": "%s"} 2: {"title": "%s", "type": "single-select", "outcomes": [%s], "category": "%s", "lang": "%s"} 3: {"title": "%s", "type": "multiple-select", "outcomes": [%s], "category": "%s", "lang": "%s"} 4: {"title": "%s", "type": "datetime", "category": "%s", "lang": "%s"} ``` -------------------------------- ### Vouching Interface Source: https://docs.kleros.io/products/proof-of-humanity/proof-of-humanity-2.0-integration-guide.md Enables users to add or remove vouches for other accounts and manage advanced vouching with signature support. ```APIDOC ## Vouching Interface ### Description Enables users to add or remove vouches for other accounts and manage advanced vouching with signature support. ### Functions - `addVouch(address _account, bytes20 _humanityId) external`: Adds a vouch for a given account and humanity ID. - `removeVouch(address _account, bytes20 _humanityId) external`: Removes a vouch for a given account and humanity ID. - `vouches(address _voucher, address _claimer, bytes20 _humanityId) external view returns (bool)`: Checks if a voucher has vouched for a claimer. - `advanceState(address _claimer, address[] calldata _vouches, SignatureVouch[] calldata _signatureVouches) external`: Manages advanced vouching with signature support. ```