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

Чтобы взаимодействовать со смарт-контрактом KurateDAO напрямую, используйте API ниже. Смарт-контракт может быть найден на [Github](https://github.com/KurateDAO/KurateDAO/blob/main/src/contracts/Kurate.sol).&#x20;

### База данных

#### 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)
```

### Schema

[JSON Schema](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"]
}
```

### Методы строк

#### Минт строки (оплачиваемый)

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

#### Получить строки

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

#### Стейк строк (оплачиваемый)

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

#### Вынос решения по строке

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

#### Сжигание строки (удаление)

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

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

### Другое

#### Запускать задачу 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-ru.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.
