> For the complete documentation index, see [llms.txt](https://maythuyle.gitbook.io/kuratedao.vietnamese/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://maythuyle.gitbook.io/kuratedao.vietnamese/api/smart-contract.md).

# Smart Contract

Để tương tác trực tiếp với hợp đồng thông minh KurateDAO, API như sau. Hợp đồng thông minh có thể được tìm thấy trên [Github](https://github.com/KurateDAO/KurateDAO/blob/main/src/contracts/Kurate.sol) .

Cơ sở dữ liệu

### Databases (Cơ sở dữ liệu)

#### 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 (lược đồ)

Một [JSON Schema](https://json-schema.org/) được lưu trữ trong hợp đồng thông minh để khách hàng biết liệu các hàng có phù hợp với cấu trúc của cơ sở dữ liệu hay không.

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

### Row Method (Phương pháp hàng)

#### Mint Row ( phải trả)

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

#### Get Rows

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

#### Stake Row (phải trả)

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

Cơ sở dữ liệu là một [living document](https://en.wikipedia.org/wiki/Living_document). Cũng giống như người quản lý có khả năng thêm một hàng vào cơ sở dữ liệu, họ cũng có khả năng loại bỏ (ghi) một hàng khi nó bây giờ còn hữu ích.

### Khác <a href="#other" id="other"></a>

#### Chạy Cron Job <a href="#run-cron-job" id="run-cron-job"></a>

`function cron() public`

Để phân xử các phần tử đã vượt quá khoảng thời gian chờ của đám đông và người quản lý, một hàm cron (bộ lập lịch) cần được gọi khoảng một lần mỗi phút. Ai gọi điều này đầu tiên trong mỗi chu kỳ khối sẽ nhận được một phần thưởng nhỏ

## Events (Sự kiện)

```
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();
```

## Structs (cấu trúc)

#### Database (cơ sở dữ liệu)

```
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;
}
```

#### Row

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

#### Stake

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

#### Decision

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

#### Stage

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://maythuyle.gitbook.io/kuratedao.vietnamese/api/smart-contract.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.
