Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
grammar
  • Loading branch information
ikatanic committed Dec 24, 2019
1 parent 0a5c1d0 commit 98580e8
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 11 deletions.
59 changes: 48 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,67 @@ in exchange for a reward in ether or solve other's tasks yourself.

## Definitions

**Problem** is defined by the type of its input and output, and by relation between those two.
For example, factorization problem has a positive integer as the input and a positive integer as the output (solution).
A **problem** is defined by the type of its input and output, and by relation between the two.
For example, the factorization problem has a positive integer as the input and a positive integer as the output (solution).
Output integer should be a non-trivial factor of the input integer. Otherwise the solution is not correct.

We represent a problem by an Ethereum smart contract with the following interface:
We represent a problem by an Ethereum smart contract with the following signature:

```
```solidity
contract ProblemContract {
function getDescription() public view returns(string);
function getName() public view returns(string);
function check(uint[] input, uint[] output) public pure returns (bool);
}
```

Most important method is `check`. It takes some input and output and verifies if given the output is the correct solution to the input.
See `contracts/Factorization.sol` for an example.
The most important method is `check`. It takes an input value and an output value and returns `true` iff the output value is the correct solution to the input value.

Have a look at one possible implementation of the Factorization problem contract:
```solidity
pragma solidity ^0.4.24;
contract Factorization {
string constant name = "Factorization";
string constant description = "Find a factor of a number";
function getName() public view returns(string) {
return name;
}
function getDescription() public view returns(string) {
return description;
}
function check(uint[] input, uint[] output) public pure returns (bool) {
if (input.length != 1 || output.length != 1) {
return false;
}
uint n = input[0];
uint factor = output[0];
if (1 < factor && factor < n && n % factor == 0) {
return true;
}
return false;
}
}
```

Currently, inputs and outputs are restricted to arrays of unsigned integers. This doesn't really make any problems
impossible to use, but it might be awkward to convert arbritrary input types to unsigned integers.
impossible to represent, but it might be awkward to convert arbritrary input types to unsigned integers.

**Task** is an input to a problem, along with some reward in ether. The platform ensures that
whoever comes first and submits the solution to the task (which passes the validation by the solution checker) gets the reward.
A **task** is an input to a problem, along with some reward in ether. The platform ensures that
whoever first submits the solution to the task (which passes the validation by the `check` function) gets the reward.

For instance, Alice could submit a factorization task with input number being 30. Bob could then
For instance, Alice could submit a factorization task with the input number being 30. Bob could then
submit 2 as a solution and win the prize.

To prevent cheating, solution submitting is implemented as two-phase process: commit phase and reveal phase.
To prevent cheating, solution submitting is implemented as a two-phase process:
1. **commit phase**: a salted hash of solver's address and the solution is submitted
2. **reveal phase**: raw solution and the hash salt are submitted

## Developing

Expand Down Expand Up @@ -76,3 +110,6 @@ Optionally, install [MetaMask](https://metamask.io/) extension and configure it
the test blockchain you set up.

Open `localhost:3000` in your browser to start using the dapp.

## Screenshot
![Image of Yaktocat](screenshot.png)
Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 98580e8

Please sign in to comment.