# Смарт-контракт

Для безпосередньої взаємодії зі смарт-контрактом KurateDAO API є наведеним нижче. Смарт-контракт можна знайти на [Github](https://github.com/KurateDAO/KurateDAO/blob/main/src/contracts/Kurate.sol).

### База даних

#### mintDatabase - створення бази даних

```
function mintDatabase(
    string memory title, 
    string memory description, 
    string memory curatorName, 
    string memory curatorUrl, 
    uint timeoutCrowd, 
    uint timeoutCurator, 
    uint thresholdCurator,
    string memory jsonSchema
) public payable
```

#### getDatabasesAll - отримання всіх баз даних

```
function getDatabasesAll() public view returns(DatabaseSimple[] memory)
```

### Схема&#x20;

[JSON Схема](https://json-schema.org/) зберігається в смарт-контракті, щоб клієнти знали, чи відповідають рядки структурі бази даних.

```
{
     "$schema": "http://json-schema.org/draft-04/schema#",
     "description": "VIPs",
     "type": "object",
     "properties": {
         "name": {
             "type": "string"
         },
         "guests": {
             "type": "number"
         }
     },
     "required": ["name","guests"]
}
```

### Методи рядків

#### Mint Row (payable) - карбування рядка (оплачувано)

```
function mintRow(uint databaseId, string memory json) public payable
```

#### Get Rows - отримання рядків

```
function getRows(uint databaseId) view public returns ( RowSimple[] memory)
```

#### Stake Row (payable) - стейт строки ( оплачувано)

```
function stakeRow(uint databaseId, uint rowId, Decision decision) public payable
```

#### Adjudicate Row - ухвалення вироку для строки

```
function adjudicateRow(uint databaseId, uint rowId, Decision decision) public
```

#### Burn Row - спалення строки

```
function burnRow(uint databaseId, uint rowId) public
```

База даних це [живий документ](https://en.wikipedia.org/wiki/Living_document).  Так само, як куратор має можливість додати рядок до бази даних, він також має можливість видалити (записати) рядок, коли він стане більш корисним.

### Інші методи

#### Run Cron Job - запустити планову роботу Cron

`function cron() public`

Щоб винести вирок по елементам, які вийшли за межі періоду очікування натовпу та куратора, функцію cron (планувальника) потрібно викликати приблизно раз на хвилину. Той, хто виклюка її  першим у кожному циклі блоку, отримає невелику винагороду.

## Події

```
event MintedDatabase(uint databaseId);
event MintedRow(uint databaseId, uint rowId);
event Staked(uint databaseId, uint rowId);
event Adjudicated(uint databaseId, uint rowId, Decision decision);
event BurntRow(uint databaseId, uint rowId);
event Croned();
```

## Структура

#### Бази даних

```
struct Database {
    uint                            id;
    string                          title;
    string                          description;
    string                          curatorName;
    string                          curatorUrl;
    uint                            timeoutCrowd;
    uint                            timeoutCurator;
    uint                            thresholdCurator;
    string                          jsonSchema;
    address                         owner;
    uint                            timestamp;
    Row[]                           rows;
}
```

#### Рядок

```
struct Row {
    uint                            id;
    string                          json;
    uint                            timestamp;
    mapping(uint => Stake)          stakes;
    uint                            stakeLength;
    address                         owner;
}
```

#### Стейкінгу

```
struct Stake {
    uint                            amount;
    Decision                        decision;
    Stage                           stage;
    address                         owner;
    uint                            timestamp;
}
```

#### Рішення

```
enum Decision { 
    INCLUDE, 
    EXCLUDE, 
    TBD 
}
```

#### Етап

```
enum Stage { 
    CROWD, 
    CURATOR, 
    DATABASE 
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kuratedao-ua.gitbook.io/kuratedao/api/smart-kontrakt.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

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.
