KurateDao.Vietnamese
  • Giới thiệu
  • Các ví dụ
  • KURATEDAO
    • Roles (vai trò)
    • Protocol (giao thức)
    • Analysis (phân tích)
    • Participation (sự tham gia)
  • API
    • JSON API
    • Smart Contract
    • Front End (Giao diện người dùng)
  • TÀI LIỆU THAM KHẢO
    • Bảng chú giải
    • Phương tiện truyền thông
    • Liên kết và Hợp đồng
    • Quốc tế
Powered by GitBook
On this page
  • Databases (Cơ sở dữ liệu)
  • Schema (lược đồ)
  • Row Method (Phương pháp hàng)
  • Khác
  • Events (Sự kiện)
  • Structs (cấu trúc)
  1. API

Smart Contract

Hợp đồng thông minh

PreviousJSON APINextFront End (Giao diện người dùng)

Last updated 3 years ago

Để 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 .

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 đồ)

{
     "$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

Khác

Chạy Cron Job

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 
}

Một đượ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.

Cơ sở dữ liệu là một . 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.

Github
JSON Schema
living document