Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create bmip-0775 #9

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions bimp-0775-CN-比原资产跨链通用命名标识方案.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
BMIP: 775
Layer: Bytom Asset Protocol(BAP)
Title: Bytom Asset Naming Standard
Author: PPkPub <ppkpub@gmail.com>
Comments-Summary: No comments yet.
Comments-URI:
Status: Draft
Type: Standards Track
Created: 2019-12-23

1.概要(Abstract)

结合比原主侧链的资产跨链机制,基于主链资产的资产代号(symbol),结合PPk社区的ODIN标识来建立一个比原资产唯一命名标识体系,关联定义和实现资产相关信息和交易服务接口,以方便开发跨比原主侧链、跨其它链和平台的新型数字资产应用。


2.规范(Specification)

2.1 命名标识定义
结合PPk社区的ODIN标识来建立一个比原资产唯一命名标识体系,格式定义如下:
ppk:btm/asset/[SYMBOL]/
其中
ppk:btm为比原已经注册拥有的根标识前缀;
asset为二级扩展标识,对应资产命名空间;
SYMBOL对应自行发布的具体资产,取值为在比原主链发行时所输入的资产代号, 英文字母需采用大写。
举例:
ppk:btm/asset/BHT/
ppk:btm/asset/USDT/

注:对于比原币,特别定义标识为 ppk:btm/ ,以区分于其它资产

2.2 重名冲突解决方案
因为在比原主链新建资产时,所输入的资产代号(symbol)只在客户端体现,并不在链上检查是否存在重复,所以此处定义的命名标识规范明确,遇到重复代号的资产,以第一个在链上发行(issue)的交易记录为准,先发行先拥有,其后发行重复资产代号(symbol)的资产将只能使用哈希编号作为唯一标识。

2.3 通过命名标识所提供的比原主链资产相关信息和交易服务接口
可参考比原资产协议BAP2(https://github.com/Bytom/bmips/blob/master/bmip-0002.mediawiki),
结合PPk应用扩展协议PTAP02(https://github.com/ppkpub/docs/tree/master/PTAP/PPK_PTAP_02.txt),
进一步定义类似ERC20/ERC721的应用服务接口标准,
这里以获取比原主链上发行的USDT资产定义数据举例如下,可参考以进一步扩充定义:

接口URI:
ppk:btm/asset/USDT/metadata()#

返回结果:
JSON字符串,说明示例如下:
{
"name":"USDT", //币种显示缺省名称,一般为英文
"symbol":"USDT", //币种代号,英文字母需大写
"type":"token", //类型,可选取值为coin,token
"native_id":"4483893ef7d......69a6f5703", //对应的链上资产ID
"base_coin_uri":"ppk:btm/", //对于token需要填写对应的基础币种标识
"total_supply": "100000000000000" , //供应量,以类似satoshi的最小单位,采用字符串避免大数问题,可选
"min_transfer_amount":100000, //最小转账金额,整数,以类似satoshi的最小单位
"decimals":8, //由类似satoshi的最小单位换算到标准单位的小数位数 ,如1BTM换算最小单位的小数位数为8

"logo":"", //默认图标网址
"quorum":1, //交易签名门限
"issue_timestamp":1524499200, //发行时间
"address_count":"12566", //持有人数
"is_bap2":true, //是否为符合BAP2规范的资产
"reissue":"true", //是否可以重复发行
"description":"Bytom Official USDT", //更多说明
"issuance_program":null, //关联的发行合约地址
"decode_program":null, //关联的解码合约地址

"tx_explorer_url":"https://blockmeta.com/tx/" //建议的交易查询地址前缀
}

2.4 命名标识对比原侧链的支持方案
比原侧链可以自行注册和拥有ODIN根标识,再具体定义扩展标识,并在扩展标识涉及比原资产时,对应关联主链资产标识中的资产ODIN标识。

例如:
假设MOV侧链的ODIN标识为 ppk:bystack/mov/
则可以定义该侧链上的USDT资产对应扩展标识为 ppk:bystack/mov/asset/USDT
并在其资产定义数据结构中,提供下述属性字段,来说明其相关的主链资产标识:
"cross_related_uris" : {
"ppk:btm/asset/USDT/" : {"in":true,"out":true}
}
注:
1."in"表示是否支持跨链转入,"out"表示是否支持跨链转出;
2.可以进一步扩充定义涉及跨链交易的更多信息。

应用就可以检查主侧链相关资产标识信息中的native_id,并确保一致,避免出错或伪造风险。

2.5 命名标识对其它链的支持方案
其它链可以自行注册和拥有ODIN根标识,再具体定义其链上资产对应的扩展标识,并在涉及比原资产时,对应关联比原资产的ODIN标识。

例如:
假设以太坊链的ODIN标识为 ppk:eth/
则可以定义以太坊链上的USDT资产对应扩展标识为 ppk:eth/erc20/USDT
并在其资产定义数据结构中,提供下述属性字段,来说明其关联的比原主侧链上的资产标识:
"cross_related_uris" : {
"ppk:btm/asset/USDT/" : {"in":true,"out":true},
"ppk:bystack/mov/asset/USDT/" : {"in":true,"out":true}
}
注:
1."in"表示是否支持跨链转入,"out"表示是否支持跨链转出;
2.可以进一步扩充定义涉及跨链交易的更多信息。

同样的,在比原链上也可以关联其它链上的资产标识,这样应用就可以很方便地判断不同链间资产的相关性。

3 实现(Implementation)
可以通过下述API接口来查询比原主链上已发行的资产,并提取和保存命名标识体系所需的资产标识基础数据。
https://blockmeta.com/api/v3/list-asset?page=1&limit=100

然后按PPk对等可信传输协议PTTP(https://github.com/ppkpub/docs/blob/master/PPK_PTTP_SPEC.txt)来实现相关的资产服务接口。
参考源码实现案例:https://github.com/ppkpub/AP/tree/master/php2_coin_api

139 changes: 139 additions & 0 deletions bmip-0775.mediawiki
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
BMIP: 775
Layer: Bytom Asset Protocol(BAP)
Title: Bytom Asset Naming Standard
Author: PPk community <ppkpub@gmail.com>
Comments-Summary: No comments yet.
Comments-URI:
Status: Draft
Type: Standards Track
Created: 2019-12-23


1.Abstract
===========
Based the cross-chain design of the Bytom project, we can establish a unique naming system based blockchain for the Bytom asset, by integrating the symbol of the asset that issued on the Bytom main-chain with the ODIN naming protocol from the PPk community. Further more, we can define and implement the universal interfaces such as the asset information and transaction services , which would help the development of new digital asset applications across the Bytom main-chain,Bystack side-chains and more other chains and platforms.

2.Specification
================
2.1 Naming Scheme

The unique naming scheme of Bytom asset is based the ODIN scheme(https://ppkpub.github.io/docs/English/EN_PPK_ODIN.txt).
The detail is as follows:

URI Scheme:

ppk:btm/asset/[SYMBOL]/

Comments:

(a)"ppk:btm" is the root ODIN that had been registered by Bytom project.

(b)"asset" is second-level extension identifier witch means the asset namespace.

(c)"SYMBOL" is the specific asset symbol which is issued on Bytom main-chain.(All letters need to be capitalized)

Examples:

ppk:btm/asset/BHT/
ppk:btm/asset/USDT/

Special case:

For the Bytom coin, it is specifically defined as "ppk:btm/" witch is different from other assets.

2.2 Duplicate asset symbol conflict

While creating a new asset of the Bytom main-chain, the entered asset symbol is only checked on the client node, and there is no check on the main-chain for duplicates. Therefore, the naming specification defines here that the first transaction record issued on the chain shall own the unique symbol code. and the latter assets would use the HASH ID as it's unique symbol in the ODIN name.

2.3 The information and transaction service interfaces related to the Bytom asset

Based the Bytom Asset Protocol(BAP02, https://github.com/Bytom/bmips/blob/master/bmip-0002.mediawiki),
and the PPk Application Protocol(PTAP02,https://github.com/ppkpub/docs/tree/master/PTAP/PPK_PTAP_02.txt),
we can use the naming scheme to define Bytom application interface standards like ERC20/ERC721 of Ethereum.

Here is an example of getting the USDT asset definition information issued on the Bytom main-chain.
Refer it, we can define more interfaces.

API URI:
ppk:btm/asset/USDT/metadata()#

Return:
JSON String,for example:
{
"name":"USDT", //the name of the token.(string shoud be less than 30 characters)
"symbol":"USDT", //symbol code.(all letters need to be capitalized)
"type":"token", //asset type(selectable value is coin and token)
"native_id":"4483893ef7d......69a6f5703", //the orginal asset ID on the chain.
"base_coin_uri":"ppk:btm/", //the base coin identifier for carrying the token.
"total_supply": "100000000000000" , //supply, the unit is the smallest like satoshi. use string to avoid too large numbers. Optional
"base_miner_fee":100000, //Minimum miner cost, integer, the unit is the smallest like satoshi.
"min_transfer_amount":100000, //Minimum transfer amount, integer, the unit is the smallest like satoshi.
"decimals" : 8, // the number of decimal places for the smallest unit like satoshi
"logo":"", //Default icon URL
"quorum":1, //Define the threshold number of the possible signing keys that must sign a transaction to issue units of this token.
"issue_timestamp":1524499200, //issued time
"address_count":"12566", //The address counter of holders
"is_bap2":true, //whether is a BAP2-compliant asset.
"reissue":"true", //define the flag whether asset can be issued more than once
"description":"", //include an asset description consisting of arbitrary key-value data - e.g. {"Email":"foo@bar.com"}
"issuance_program":null, //related issued program ID
"decode_program":null, //related decode program ID
"tx_explorer_url":"https://blockmeta.com/tx/" //suggested service for querying transaction.
}

2.4 Support the Bystack side-chain

The Bystack side-chain can register the root ODIN by own, and then define the extended identifier specifically for the asset on side-chain, which can carry the relationship to the asset on Bytom main-chain.

For example:
Suppose an ODIN identifier of a Bystack side-chain is "ppk:bystack/mov/" .
Define the extended identifier specifically for the asset on side-chain such as "ppk:bystack/mov/asset/USDT/" .
Then we can use the API URI as follows to get the definition information of the asset on side-chain :
ppk:bystack/mov/asset/USDT/metadata()#

In the response, provide the following attribute fields which describe the relationship to the asset on Bytom main-chain.

"cross_related_uris" : {
"ppk:btm/asset/USDT/" : {"in":true,"out":true}
}

Comments:
(a)"in" : Whether support cross-chain transfer into side-chain;
(b)"out": Whether support cross-chain transfer out of side-chain;
(c)The definition can be further extended to include more informations for cross-chain transaction.

The application can check the native_id in the asset definition by the identifiers between the main-chain and side-chain, which would help to avoid the risk of incorrect or fake asset.

2.5 Support the other blockchains

Other chains can register the root ODIN by own, and then define the extended identifier specifically for the asset on it, which can carry the relationship to the asset on Bytom main-chain.

For example:
Suppose an ODIN identifier of one Ethereum is "ppk:eth/" .
Define the extended identifier specifically for the ERC20 asset on Ethereum such as "ppk:eth/erc20/USDT" .
Then we can use the API URI as follows to get the definition information of the asset on Ethereum :
ppk:eth/erc20/USDT/metadata()#

In the response, provide the following attribute fields which describe the relationship to the asset on Bytom main-chain or Bystack side-chains.
"cross_related_uris" : {
"ppk:btm/asset/USDT/" : {"in":true,"out":true},
"ppk:bystack/mov/asset/USDT/" : {"in":true,"out":true}
}

Comments:
(a)"in" : Whether support cross-chain transfer in;
(b)"out": Whether support cross-chain transfer out;
(c)The definition can be further extended to include more informations for cross-chain transaction.

Similarly, the asset issued on the Bytom can carry the relationship to the asset on other chains too. Then the application can easily judge and process the cross-chain transaction of assets between different chains by the unique naming protocol defined here.

3. Implementation
==================
We can query the issued assets on the Bytom main-chain by the following API, then extract and save the basic asset identification data required by the naming system.
https://blockmeta.com/api/v3/list-asset?page=1&limit=100

Then we can implement the related asset service interfaces by PPk transfer protocol(PTTP, https://github.com/ppkpub/docs/blob/master/PPK_PTTP_SPEC.txt).

Reference source code:
https://github.com/ppkpub/AP/tree/master/php2_coin_api