Request form
Cookbook may introduce a token in the future. Share and contribute to be eligible for future airdrops.
close icon
relevant tag icon
Kleros Arbitration
copy icon
kleros
• version 1.0.0
Utility
Bounty

Kleros Arbitration

The main (v2) Kleros contract with dispute resolution logic for the Athena release. Allows on-chain disputes to be resolved by a jury.

*Visit desktop site to download or deploy

Version

1.0.0

Creator

kleros

Recent Use

🍞 0x22a6 saved

Last Publish

10/25/2022
Any contract you deploy is yours.
Fully owned and controlled by your wallet.
Documentation
Source Code
executeGovernorProposal(address) :
This function is used to execute a proposal from the governor of a smart contract. It takes three parameters: an address, an amount, and some data. The function then calls the address provided with the amount and data provided. This allows the governor to send funds to a specified address and include additional data with the transaction. (autogenerated documentation)
changeGovernor(address) :
This function allows the current governor of the contract to change the address of the governor. It does this by taking in an address as an argument and setting the governor variable to that address. This function can only be called by the current governor. (autogenerated documentation)
changePinakion() :
This function allows the governor of the contract to change the Pinakion value stored in the contract. The function takes in a new Pinakion value as an argument and sets the pinakion variable in the contract to the new value. (autogenerated documentation)
changeRNGenerator() :
This function allows the governor of the contract to change the random number generator (RNG) used by the contract. It sets the new RNG to the _RNGenerator parameter and then checks if the contract is in the generating phase. If it is, it sets the RNBlock to the current block number plus one and requests a random number from the new RNG. (autogenerated documentation)
changeMinStakingTime() :
This function allows the governor of the contract to change the minimum staking time for users. The function takes in a uint parameter, _minStakingTime, which is the new minimum staking time that the governor wants to set. The function then sets the minStakingTime variable to the new value. (autogenerated documentation)
changeMaxDrawingTime() :
This function allows the governor of the contract to change the maximum drawing time of the contract. The function takes in a uint (unsigned integer) as an argument, which is the new maximum drawing time. The function then sets the maxDrawingTime variable to the new value. (autogenerated documentation)
createSubcourt(uint96,bool) :
This function creates a new subcourt. It takes in several parameters, including the parent court, whether votes should be hidden, the minimum stake, the alpha value, the fee for jurors, the number of jurors for court jumps, and an array of times per period. It then adds the new court to the courts array and creates a new sortition sum tree for the subcourt. Finally, it adds the subcourt to the parent court's children array. (autogenerated documentation)
changeSubcourtMinStake(uint96) :
This function allows the governor to change the minimum stake for a subcourt. It requires that the minimum stake for the subcourt is not lower than the minimum stake of its parent court, and that the minimum stake for any of its subcourts is not higher than the new minimum stake. If these conditions are met, the minimum stake for the subcourt is updated. (autogenerated documentation)
changeSubcourtAlpha(uint96) :
This function allows the governor to change the alpha value of a subcourt. Alpha is a parameter that determines the amount of tokens that are required to be staked in order to submit a dispute to the subcourt. The function takes two parameters, the subcourt ID and the new alpha value, and updates the alpha value of the specified subcourt. (autogenerated documentation)
changeSubcourtJurorFee(uint96) :
This function allows the Governor to change the fee for jurors in a specific subcourt. It takes two parameters: a 96-bit unsigned integer representing the subcourt ID, and an unsigned integer representing the new fee for jurors. The function then sets the feeForJuror property of the court object associated with the subcourt ID to the new fee. (autogenerated documentation)
changeSubcourtJurorsForJump(uint96) :
This function allows the Governor to change the number of jurors required for a court jump in a subcourt. It takes two parameters: a 96-bit unsigned integer representing the subcourt ID, and an unsigned integer representing the number of jurors required for a court jump. The function then sets the jurorsForCourtJump property of the subcourt to the specified value. (autogenerated documentation)
changeSubcourtTimesPerPeriod(uint96) :
This function allows the governor to change the times per period for a specific subcourt. The function takes two parameters, a uint96 _subcourtID which is the ID of the subcourt to be modified, and a uint[4] _timesPerPeriod which is an array of four uints representing the times per period for the subcourt. The function then sets the timesPerPeriod property of the subcourt to the new value. (autogenerated documentation)
passPhase() :
This function is used to transition between the different phases of the staking process. It checks the current phase and then performs the necessary steps to move to the next phase. For example, if the current phase is staking, it will check that the minimum staking time has passed and that there are disputes that need jurors. It will then request a random number from the RNGenerator and transition to the generating phase. If the current phase is generating, it will get the uncorrelated random number from the RNGenerator and transition to the drawing phase. Finally, if the current phase is drawing, it will check that there are no disputes without jurors or that the maximum drawing time has passed and transition to the staking phase. Once (autogenerated documentation)
passPeriod() :
This function is used to pass a dispute to the next period. It takes in a dispute ID as an argument and checks the current period of the dispute. Depending on the period, it will check if the time for that period has passed or if all jurors have voted/drawn/committed. If the conditions are met, the dispute is passed to the next period. The lastPeriodChange variable is updated and an event is emitted to notify of the new period. (autogenerated documentation)
setStake(uint96,uint128) :
This function allows a user to set a stake for a particular subcourt. It requires the user to provide the subcourt ID and the amount of stake they wish to set. The function then calls the _setStake() internal function, which checks that the user has sufficient funds to set the stake and then updates the stake amount for the specified subcourt. (autogenerated documentation)
executeDelayedSetStakes() :
This function executes a set of delayed set stake operations. It takes an argument of _iterations, which is the number of delayed set stake operations to execute. It then checks if the number of iterations is greater than the last delayed set stake, and if so, it sets the actual iterations to the difference between the last and next delayed set stake. It then loops through the delayed set stakes from the next delayed set stake to the new next delayed set stake, executing each set stake operation and deleting it from the delayed set stakes mapping. Finally, it sets the next delayed set stake to the new next delayed set stake. (autogenerated documentation)
drawJurors() :
This function is used to draw jurors for a dispute. It takes in two parameters, the dispute ID and the number of iterations. It then checks that the end index is greater than the current draws in round. It then uses the stakePathIDToAccountAndSubcourtID function to draw a juror from the sortitionSumTrees. The drawn address is then stored in the votes array and the locked tokens of the juror is incremented. An event is then emitted and if the last iteration is reached, the disputesWithoutJurors is decremented. (autogenerated documentation)
castCommit(bytes32) :
This function allows a user to cast a commit for a dispute. It takes in the dispute ID, an array of vote IDs, and a commit as parameters. It first checks that the commit is not equal to 0 and that the caller owns the vote. It then sets the commit for the vote to the commit provided. Finally, it increments the number of commits in the round. (autogenerated documentation)
castVote() :
This function allows a user to cast a vote in a dispute. It takes in the dispute ID, an array of vote IDs, the choice the user is voting for, and a salt value. It then checks that the caller owns the vote, that the commit matches the choice in subcourts with hidden votes, and that the vote has not already been cast. It then updates the choice and voted status of the vote, and updates the vote counter for the dispute. The vote counter is updated by incrementing the count for the chosen choice, and if the count is greater than the count for the current winning choice, the winning choice is updated. If the count is equal to the count for the current winning choice, the vote counter is (autogenerated documentation)
computeTokenAndETHRewards() :
This function computes the token and ETH rewards for a given dispute and appeal. It first checks if the vote is tied, and if so, it divides the penalties and fees for the appeal by the total number of active votes. If the vote is not tied, it divides the penalties and fees by the number of votes for the winning choice. (autogenerated documentation)
execute() :
This function is used to execute the results of a dispute in the Pinakion court system. It is called when the voting period for a dispute has ended and the results need to be implemented. The function takes three parameters: the dispute ID, the appeal number, and the number of iterations. The function first sets the lockInsolventTransfers variable to false, which allows transfers to be made even if the sender does not have enough funds. It then retrieves the dispute from storage and calculates the end of the iteration loop. It then checks if the vote was not tied and the winning choice had no votes, and if so, sets the end of the loop to the length of the votes array. Otherwise, (autogenerated documentation)
executeRuling() :
This function executes the ruling of a dispute. It takes in a dispute ID as an argument and checks if the ruling has already been executed. If not, it sets the ruling to true and determines the winning choice by looking at the vote counters. Finally, it calls the rule function of the arbitrated contract, passing in the dispute ID and the winning choice. (autogenerated documentation)
createDispute() :
This function creates a new dispute in the Arbitrable contract. It takes two parameters, the number of choices and extra data, and requires a payment of the arbitration fee. It then stores the dispute in the disputes array, and sets the subcourtID, arbitrated address, number of choices, and period. It also adds the value of the arbitration fee to the total fees for jurors, and adds the minimum stake for jurors to the tokens at stake per juror. Finally, it emits a DisputeCreation event. (autogenerated documentation)
appeal() :
This function allows a dispute to be appealed to a higher court. It requires the appellant to pay an appeal fee, and sets the dispute period to evidence. It also updates the dispute's vote and vote counter arrays, and adds the appeal fee to the total fees for jurors. Finally, it emits two events, AppealDecision and NewPeriod. (autogenerated documentation)
proxyPayment(address) :
This function is a proxy payment function that allows a user to make a payment to an address _owner. It checks if the payment is allowed and returns a boolean value of either true or false. If the payment is allowed, the function will return true, otherwise it will return false. (autogenerated documentation)
onTransfer(address,address) :
This function is used to prevent insolvent transfers from taking place. It checks if the balance of the sender after the transfer is less than the amount of tokens they have staked or locked. If this is the case, the transfer is not allowed and the function returns false. Otherwise, the transfer is allowed and the function returns true. (autogenerated documentation)
onApprove(address,address) :
This function is used to approve a certain amount of tokens to be transferred from one address to another. It takes three parameters: the address of the owner, the address of the spender, and the amount of tokens to be transferred. The function then returns a boolean value of true, indicating that the transfer is allowed. (autogenerated documentation)
arbitrationCost() :
This function calculates the cost of arbitration for a given subcourt and minimum number of jurors. It takes in the extra data as an input, which is then parsed to extract the subcourt ID and minimum number of jurors. The cost is then calculated by multiplying the fee for each juror by the minimum number of jurors. (autogenerated documentation)
appealCost() :
This function calculates the cost of appealing a dispute. It takes in two parameters, the dispute ID and extra data, and returns the cost of the appeal. The cost is determined by the number of jurors that have already voted on the dispute, and the fee for jurors set by the court. If the number of jurors is greater than or equal to the number of jurors required for a court jump, then the cost is determined by the fee for jurors set by the parent court. Otherwise, the cost is determined by the fee for jurors set by the current court. (autogenerated documentation)
appealPeriod() :
This function returns the start and end times of the appeal period for a given dispute. It takes in a dispute ID as an argument and looks up the dispute in the disputes mapping. If the dispute is in the appeal period, the start and end times of the appeal period are returned. Otherwise, 0 is returned for both the start and end times. (autogenerated documentation)
disputeStatus() :
This function returns the status of a dispute based on its dispute ID. It checks the period of the dispute and returns a DisputeStatus enum value accordingly. If the period is less than the appeal period, the status is set to Waiting. If the period is less than the execution period, the status is set to Appealable. Otherwise, the status is set to Solved. (autogenerated documentation)
currentRuling() :
This function returns the current ruling of a dispute with a given dispute ID. It first retrieves the dispute from storage and then checks if the last vote counter is tied. If it is, the ruling is set to 0, otherwise it is set to the winning choice of the last vote counter. (autogenerated documentation)
_setStake(address,uint96,uint128) :
This function allows a user to set a stake for a particular subcourt. It first checks to make sure that the subcourtID is valid and that the stake is within the minimum stake requirement. It then checks to make sure that the user has enough Pinakion tokens to cover the stake. If all of these conditions are met, the stake is set and the user's total staked tokens is updated. The stake is then added to the sortition sum tree for the subcourt and all of its parent courts. Finally, an event is emitted to indicate that the stake has been set. (autogenerated documentation)
extraDataToSubcourtIDAndMinJurors() :
This function takes in a byte array as an argument and returns two values: a subcourtID and a minimum number of jurors. It first checks to see if the byte array is at least 64 bytes long. If it is, it loads the subcourtID and minJurors values from the byte array. If the subcourtID is greater than the length of the courts array, it sets the subcourtID to 0. If the minJurors value is 0, it sets the minJurors to the minimum number of jurors. If the byte array is not at least 64 bytes long, it sets the subcourtID to 0 and the minJurors to the minimum number of jurors. (autogenerated documentation)
accountAndSubcourtIDToStakePathID(address,uint96) :
This function takes an Ethereum address and a 96-bit subcourt ID as inputs and returns a 32-byte stakePathID as an output. It does this by first allocating a 32-byte memory space at the address 0x40, then looping through the first 12 bytes of the address and storing them in the memory space, followed by looping through the remaining 20 bytes of the subcourt ID and storing them in the memory space. Finally, it returns the 32-byte stakePathID stored in the memory space. (autogenerated documentation)
stakePathIDToAccountAndSubcourtID(bytes32) :
This function takes a bytes32 _stakePathID as an input and returns an address account and a uint96 subcourtID as outputs. It does this by first loading the memory address 0x40 into a pointer, then looping through the bytes of the _stakePathID and storing them in the memory address pointed to by the pointer. Finally, it loads the address stored in the pointer into the account variable and sets the subcourtID variable to the _stakePathID. (autogenerated documentation)
getSubcourt(uint96) :
This function retrieves the children and timesPerPeriod of a given subcourt. It does this by accessing the Court storage struct associated with the given subcourtID and returning the children and timesPerPeriod values stored in the struct. (autogenerated documentation)
getVote() :
This function retrieves the details of a vote from a dispute. It takes three parameters: the dispute ID, the appeal number, and the vote ID. It returns the address of the account that cast the vote, the commit associated with the vote, the choice that was made, and a boolean indicating whether the vote has been cast. The function accesses the storage of the contract to retrieve the vote details. (autogenerated documentation)
getVoteCounter() :
This function retrieves the vote counter associated with a given dispute and appeal. It returns the winning choice, the counts for each choice, and whether the vote is tied. The function accesses the Dispute and VoteCounter storage variables associated with the given dispute and appeal, and assigns the winningChoice, counts, and tied variables to the corresponding values in the VoteCounter storage variable. (autogenerated documentation)
getDispute() :
This function retrieves the details of a dispute from the blockchain. It takes in a dispute ID as an argument and returns an array of values related to the dispute, such as the length of the votes, the tokens at stake per juror, the total fees for jurors, the votes in each round, the repartitions in each round, and the penalties in each round. (autogenerated documentation)
getJuror(address) :
This function retrieves the subcourtIDs associated with a given account address from the jurors mapping. The jurors mapping is a mapping of account addresses to Juror structs, which contain the subcourtIDs associated with that address. The function takes in an account address as an argument and returns an array of uint96 subcourtIDs associated with that address. (autogenerated documentation)
stakeOf(address,uint96) :
This function returns the stake of a given account in a given subcourt. It does this by first converting the account address and subcourt ID into a stake path ID, and then using this stake path ID to look up the stake in the SortitionSumTree. (autogenerated documentation)

Get Cookin'
share iconShare

copy iconDownload Source
copy iconnpx cookbookdev i kleros-arbitration-v2
copy icon

Recent Use

🍞 0x22a6 saved

Last Publish

10/25/2022

Version

1.0.0

Creator

kleros

Cookbook is free.
Any contract you deploy is yours.
Your contract is owned and controlled by you.