Skip to content

Latest commit

 

History

History
199 lines (139 loc) · 6.65 KB

OEP-71.md

File metadata and controls

199 lines (139 loc) · 6.65 KB
  OEP: 71
  Title: DDXF DToken Standard
  Author: lucas7788<[email protected]>
  Type: Standard
  Status: Accepted
  Created: 2018-07-03

Abstract

Sub-contract of DDXF series, a standard proposal to combine off-chain access-token (tokenization) with on-chain token (assertization). Provides support for data management, esp., the permission control. This contract is a basic version for DToken, which cannot be retransferred. For the rest DToken contracts, which support OEP4, OEP5, and OEP8.

Motivation

As an important component of DDXF, the authority management of data is managed in the form of on-chain tokens, including data authorization management and data operation authentication, supporting the management of data operation processes in the data life cycle, and using on-chain traceability And the ability to confirm rights enables data rights management to support cross-system interoperability.According to different token characteristics, it can be further extended. This OEP is the basic data token, which only supports the defined issuance and use of data tokens.

Specification

Methods

create_token_template

fn create_token_template(creator: &Address, tt_bs: &[u8]) -> bool{}

This method will store the TokenTemplate to chain.The TokenTemplate is defined as follow:

#[derive(Clone, Encoder, Decoder)]
pub struct TokenTemplate {
   pub data_id: Option<Vec<u8>>,
   pub token_hash: Vec<Vec<u8>>,
   pub endpoint: Vec<u8>,
   pub token_name: Vec<u8>,
   pub token_symbol: Vec<u8>,
}
  • data_id is the ontid of data.
  • token_hash is bytearray of token_hash
  • endpoint is the api of the seller,
  • token_name is oep8 Token name which will be generated by this TokenTemplate
  • token_symbol is oep8 Token symbol

The parameters are of the following type:

Parameter Type Description
creator Address the owner of token template
tt_bs &[u8] the serialization result of token template

Event

This method will launch the following events:

["createTokenTemplate", creator, tt_bs, token_template_id]

update_token_template

fn update_token_template(token_template_id: &[u8], tt_bs: &[u8]) -> bool{}

Update the TokenTemplate on the chain according to the TokenTemplateId.

The parameters are of the following type:

Parameter Type Desc
token_template_id &[u8] used to mark the only TokenTemplate in the chain
tt_bs &[u8] the serialization result of token template

Event

["updateTokenTemplate", token_template_id, tt_bs]

removeTokenTemplate

fn remove_token_template(token_template_id: &[u8]) -> bool{}

Delete TokenTemplate based on TokenTemPlateId.

Parameter Type Desc
token_template_id &[u8] used to mark the only TokenTemplate in the chain

Event

["removeTokenTemplate", token_template_id]

authorizeTokenTemplate

fn authorize_token_template(token_template_id: &[u8], authorized_addr: &[Address]) -> bool{}

TokenTemplate creator authorizes other addresses to generate DTokens based on the TokenTemplateId.

Parameter Type Desc
token_template_id &[u8] used to mark the only TokenTemplate in the chain
authorized_addr &[Address] Authorized address

Event

["authorizeTokenTemplate", token_template_id, authorized_addr]

removeAuthorizeAddr

fn remove_authorize_addr(token_template_id: &[u8], authorized_addr: &[Address]) -> bool{}

Delete the specified authorized address according to TokenTemplateId.

Parameter Type Desc
token_template_id &[u8] used to mark the only TokenTemplate in the chain
authorized_addr &[Address] Authorized address

Event

["removeAuthorizeAddr", token_template_id, authorized_addr]

generateDToken

fn generate_dtoken(acc: &Address, token_template_id: &[u8], n: U128) -> bool{}

The authorized address generates DToken according to the TokenTemplateId, and records the DToken in the input parameter acc.This method can be extended, such as adding expire date, etc.

Parameter Type Desc
acc &Address authorized address or creator address
token_template_id &[u8] used to mark the only TokenTemplate in the chain
n U128 Number of DTokens generated

Event

["generateDToken", acc, acc, token_template_id,n, token_id]

useToken

fn use_token(account: &Address, token_id: &[u8], n: U128) -> bool{}

The buyer of the token has the right to consume the token. It is recommended to destroy the DToken after it is used up to save blockchain storage space.

Parameter Type Desc
account &Address buyer address
token_id &[u8] the number of purchases
n U128 represents the number of consuming token

Event

["useToken", account, token_id, n]

deleteToken

fn delete_token(account: &Address, token_id: &[u8]) -> bool{}

The TokenTemplate creator can invoke this method to delete token.Only the token owner can delete.Optionally, for expired tokens, the token initiator can delete it to save blockchain storage space.

Parameter Type Desc
account &Address buyer address
token_id &[u8] token id

Event

["deleteToken", account, token_id]

Implementation

Please refer to OEP-73, DToken+Agent+Oep8 contract.