前言
12 月 5 日,由中国移动信息技术核心研发的中移链“元交易”性能,已在 BSN-DDC 根底网络正式上线。中移链“元交易”是将多个间断的中移链链操作打包整合,保障操作事务对立、统一的快捷交易开发工具包。在中移链原有链上利用开发 SDK 的根底上,中移链“元交易”升高了区块链业务利用的开发复杂度,对构建高效便捷的区块链利用开发经济模型提供了重要撑持。
一、元交易性能
(一)性能简介
“元交易”是由平台方代终端用户(DDC 的拥有者)发动 DDC 铸造、转移或者销毁的相干交易,且本性能由平台方代付资源费和手续费。在传统的交易模式中,如发动铸造、转移、销毁等操作时,须要终端用户领有足额的链资源和 DDC 合约中的手续费,并且流程较长且简单。本次中国移动信息技术核心研发的中移链“元交易”性能,通过将交易的发起方从终端用户变更为平台方,管制发起方的数量,使发起方充值链资源变得容易,同时从根本上解决了终端用户操作简单的弊病。
(二)利用场景
1、终端用户依据交易申请参数和权限私钥,离线生成元交易的签名,并将签名值发送给平台方,由平台方代为发动元交易执行;
2、终端用户将私钥托管给平台方,平台方依据交易申请参数和权限私钥,生成元交易的签名并发动元交易执行。
二、元交易签名
(一)基于 ddc-sdk-java 进行元交易签名
1、平台方增加终端用户的公钥,参考 ddc-sdk 中的 addMetaUser 办法
1)测试用例
@Test
public void addMetaUser() {
// 设置平台方账户私钥
ChainConfig.setPk("5Jj3bPpWtbJex5DGXCLjE8c5Gr9SudFRogkwXvd1KHGGa7ZWYS1");
DDCPermissionService ddcPermissionService = new DDCPermissionServiceImpl();
// 平台方账户、终端用户账户、终端用户账户公钥
PushedTransaction pt1 = ddcPermissionService.addMetaUser("ddcplatform1", "ddcconsumer1", "EOS6R3jYqb3uZsVgzJz4HVLcYV94CLkr3u9unEzm5rpuAqUos7fqK");
System.out.println(JSONUtil.toJsonStr(pt1));
}
2)输入后果
{
"transactionId":"3ea5f2b4e21642f6862a0120a11ff9ef0fd54bc34f4d5c79884bc66b5f5bd86e",
"processed":{
"id":"3ea5f2b4e21642f6862a0120a11ff9ef0fd54bc34f4d5c79884bc66b5f5bd86e",
"blockNum":169181,
"blockTime":"2023-02-01T06:23:56.000",
"receipt":{
"cpuUsageUs":278,
"netUsageWords":21,
"status":"executed"
},
"elapsed":278,
"netUsage":168,
"scheduled":false,
"actionTraces":[
{
"actionOrdinal":1,
"creatorActionOrdinal":0,
"closestUnnotifiedAncestorActionOrdinal":0,
"receipt":{
"abiSequence":1,
"actDigest":"d3950f01d30eeee961fb2e2335b00cfdf098b19a6671d18189bf59454f8410df",
"authSequence":[
[
"ddcplatform1",
"11"
]
],
"codeSequence":1,
"globalSequence":169952,
"receiver":"ddccontract1",
"recvSequence":69
},
"receiver":"ddccontract1",
"act":{
"account":"ddccontract1",
"authorization":[
{
"actor":"ddcplatform1",
"permission":"active"
}
],
"data":{
"sender":"ddcplatform1",
"account":"ddcconsumer1",
"pubKey":"EOS6R3jYqb3uZsVgzJz4HVLcYV94CLkr3u9unEzm5rpuAqUos7fqK"
},
"hexData":"10e4a52b9b58514a10ae921a4f8a504a35454f533652336a59716233755a7356677a4a7a3448564c6359563934434c6b72337539756e457a6d357270754171556f733766714b",
"name":"addmetauser"
},
"contextFree":false,
"elapsed":125,
"console":"","trxId":"3ea5f2b4e21642f6862a0120a11ff9ef0fd54bc34f4d5c79884bc66b5f5bd86e","blockNum":169181,"blockTime":"2023-02-01T06:23:56.000","accountRamDeltas":[ ],
"accountDiskDeltas":[ ],
"returnValueHexData":"","inlineTraces":[]}
]
}
}
2、终端用户依据 DDC 拥有者查问 Nonce 值,参考 ddc-sdk 中的 getNonce 办法
1)测试用例
@Test
public void getMetaNonce() {DDC1155Service ddc1155Service = new DDC1155ServiceImpl();
// 终端用户账户
BigInteger nonce = ddc1155Service.getNonce("ddcconsumer1");
System.out.println("nonce:" + nonce);
}
2)输入后果
nonce:2
3、终端用户依据交易申请参数,生成签名所需的摘要数据(以元交易生成为例)
1)测试用例
@Test
public void getMetaMintDigest() {BigInteger amount = BigInteger.valueOf(10);
String ddcURI = "https://bitnodes.io/0001";
String memo = "memo0001";
// 上一步获取的 nonce 值
BigInteger nonce = BigInteger.valueOf(2);
// 过期工夫(工夫戳:秒)BigInteger deadline = BigInteger.valueOf(1671096761);
DDC1155MetaTransaction metaTransaction = new DDC1155MetaTransaction();
String digest = metaTransaction.getSafeMintDigest("ddcplatform1", "ddcconsumer1", "ddcconsumer1", amount, ddcURI, memo, nonce, deadline);
System.out.println("digest:" + digest);
}
2)输入后果
digest:baa58785f08da6bfe06e3675423478f8039a55f5aaf57eea195b47b9ebb6732c
4、终端用户依据权限私钥和摘要数据,生成元交易签名
1)测试用例
@Test
public void getMetaMintSignature() {
// 终端用户账户私钥
String privateKey = "5JAT6ZYDhvvWVP2UMat84BhCyu5U3PYMYtkzqXEgoPoyhdJJfV1";
// 上一步获取的摘要值
String digest = "baa58785f08da6bfe06e3675423478f8039a55f5aaf57eea195b47b9ebb6732c";
DDC1155MetaTransaction metaTransaction = new DDC1155MetaTransaction();
String signature = metaTransaction.generateSignature(privateKey, digest.getBytes(StandardCharsets.UTF_8));
System.out.println("signature:" + signature);
}
2)输入后果
signature:SIG_K1_K8W87kgEkB3EwUUTSzqU5WjnuQJ5Q11mcUx7PGJhCG5ZgALHzmxep8s9AVWXyXAEfhc9xb1Bz53biadmnRBkyRzWnYGU8W
(二)基于 ddc-sdk-js 进行元交易签名
1、平台方增加终端用户的公钥,参考 ddc-sdk 中的 addMetaUser 办法
1)测试用例
import EOSDDC from 'eos-ts-sdk';
const addMetaUserTest = (sender='ddcplatform1',account='ddcconsumer1') => {
const privateKey = "5JAT6ZYDhvvWVP2UMat84BhCyu5U3PYMYtkzqXEgoPoyhdJJfV1";
const pubKey= "EOS6R3jYqb3uZsVgzJz4HVLcYV94CLkr3u9unEzm5rpuAqUos7fqK";
let ddcPermissionService = new EOSDDC('http://101.42.251.173:3921', 'ddccontract1');
const result1 = ddcPermissionService.addMetaUser(sender, account, pubKey,privateKey);
console.log(result1);
}
2)输入后果
{
"transaction_id": "4b2b33a6e380ba4726ce6360a91435fe93ec304b0e06ee2170de5a537f254769",
"processed": {
"id": "4b2b33a6e380ba4726ce6360a91435fe93ec304b0e06ee2170de5a537f254769",
"block_num": 2363,
"block_time": "2023-01-31T07:13:47.000",
"producer_block_id": null,
"receipt": {
"status": "executed",
"cpu_usage_us": 270,
"net_usage_words": 21
},
"elapsed": 270,
"net_usage": 168,
"scheduled": false,
"action_traces": [
{
"action_ordinal": 1,
"creator_action_ordinal": 0,
"closest_unnotified_ancestor_action_ordinal": 0,
"receipt": {
"receiver": "ddccontract1",
"act_digest": "d3950f01d30eeee961fb2e2335b00cfdf098b19a6671d18189bf59454f8410df",
"global_sequence": 3129,
"recv_sequence": 64,
"auth_sequence": [
[
"ddcplatform1",
6
]
],
"code_sequence": 1,
"abi_sequence": 1
},
"receiver": "ddccontract1",
"act": {
"account": "ddccontract1",
"name": "addmetauser",
"authorization": [
{
"actor": "ddcplatform1",
"permission": "active"
}
],
"data": {
"sender": "ddcplatform1",
"account": "ddcconsumer1",
"pubKey": "EOS6R3jYqb3uZsVgzJz4HVLcYV94CLkr3u9unEzm5rpuAqUos7fqK"
},
"hex_data": "10e4a52b9b58514a10ae921a4f8a504a35454f533652336a59716233755a7356677a4a7a3448564c6359563934434c6b72337539756e457a6d357270754171556f733766714b"
},
"context_free": false,
"elapsed": 135,
"console": "","trx_id":"4b2b33a6e380ba4726ce6360a91435fe93ec304b0e06ee2170de5a537f254769","block_num": 2363,"block_time":"2023-01-31T07:13:47.000","producer_block_id": null,"account_ram_deltas": [],"account_disk_deltas": [],"except": null,"error_code": null,"return_value_hex_data":"",
"inline_traces": []}
],
"account_ram_delta": null,
"except": null,
"error_code": null
}
}
2、终端用户依据 DDC 拥有者查问 Nonce 值,参考 ddc-sdk 中的 getNonce 办法
1)测试用例
const getNonce1155 = async () => {
const Meta1155 = new EOSDDC(
'http://101.42.251.173:3921',
'ddccontract1',
);
const nonce = await Meta1155.getNonce('ddcconsumer1');
console.log(`nonce:${nonce}`);
return nonce;
};
2)输入后果
nonce:2
3、终端用户依据交易申请参数,生成签名所需的摘要数据(以元交易生成为例)
1)测试用例
const getMetaMintDigest1155 = async () => {
const amount = 10;
const ddcURI = 'https://bitnodes.io/0001';
const memo = 'memo0001';
const deadline = 1671096761;
const nonce = await getNonce1155();
const ddc1155 = new DDC1155MetaTransaction('ddccontract1');
const digest = await ddc1155.getSafeMintDigest(
'ddcplatform1',
'ddcconsumer1',
'ddcconsumer1',
amount,
ddcURI,
memo,
nonce,
deadline,
);
console.log(`digest:${digest}`);
return digest;
};
2)输入后果
digest:baa58785f08da6bfe06e3675423478f8039a55f5aaf57eea195b47b9ebb6732c
4、终端用户依据权限私钥和摘要数据,生成元交易签名
1)测试用例
const getMetaMintSignature1155 = async () => {
const key = '5JAT6ZYDhvvWVP2UMat84BhCyu5U3PYMYtkzqXEgoPoyhdJJfV1';
const digest = await getMetaMintDigest1155(); // baa58785f08da6bfe06e3675423478f8039a55f5aaf57eea195b47b9ebb6732c
const ddc1155 = new DDC1155MetaTransaction('ddccontract1');
const signature = await ddc1155.generateSignature(key, digest);
console.log(`signature:${signature}`);
return signature;
};
2)输入后果
signature:SIG_K1_K8W87kgEkB3EwUUTSzqU5WjnuQJ5Q11mcUx7PGJhCG5ZgALHzmxep8s9AVWXyXAEfhc9xb1Bz53biadmnRBkyRzWnYGU8W
三、元交易办法调用
(一)元交易生成
1、性能介绍
终端用户能够通过受权平台方调用该办法对 DDC 进行元交易生成,注:调用此接口所耗费的能量值和业务费对应的是平台方账户。
2、办法定义
1)SDK 办法定义:
DDC721Service PushedTransaction metaSafeMint(String sender, String from, String to, String ddcURI, String memo, BigInteger nonce, BigInteger deadline, String signature);
DDC1155Service PushedTransaction metaSafeMint(String sender, String from, String to, BigInteger amount, String ddcURI, String memo, BigInteger nonce, BigInteger deadline, String signature);
2)EOS 合约办法:
metamint(name sender,name from, name to, uint64_t amount, std::string ddc_uri, uint64_t business_type, std::string memo, uint64_t nonce, uint64_t deadline, signature signature);
3、输出参数
字段 | 字段名 | 类型 | 是否必传 | 备注 |
---|---|---|---|---|
sender | 调用者 | String | 是 | 调用者地址 |
from | 发送方账户 | String | 是 | |
to | 接收者账户 | String | 是 | |
amount | DDC 数量 | BigInteger | 否 | DDC721 不传 |
ddcURI | DDC 资源标识符 | String | 是 | |
memo | 附加数据 | String | 是 | |
nonce | Nonce 值 | BigInteger | 是 | |
deadline | 过期工夫 | BigInteger | 是 | |
signature | 签名值 | String | 是 |
4、输入参数
字段 | 字段名 | 类型 | 备注 |
---|---|---|---|
transactionId | 交易哈希 | String | |
processed | 执行信息 | Processed |
5、API 调用
1)测试用例(以 DDC1155 为例)
@Test
public void metaSafeMint1155() {BigInteger amount = BigInteger.valueOf(10);
String ddcURI = "https://bitnodes.io/0001";
String memo = "memo0001";
BigInteger deadline = BigInteger.valueOf(1671096761);
DDC1155Service ddc1155Service = new DDC1155ServiceImpl();
BigInteger nonce = ddc1155Service.getNonce(accountList.get(2));
DDC1155MetaTransaction metaTransaction = new DDC1155MetaTransaction();
String digest = metaTransaction.getSafeMintDigest(accountList.get(1), accountList.get(2), accountList.get(2), amount, ddcURI, memo, nonce, deadline);
String signature = metaTransaction.generateSignature(privateKey, digest.getBytes(StandardCharsets.UTF_8));
PushedTransaction pt = ddc1155Service.metaSafeMint(accountList.get(1), accountList.get(2), accountList.get(2), amount, ddcURI, memo, nonce, deadline, signature);
Map<String, Object> trxMap = ChainUtil.getInstance().parseTrxResp(pt);
System.out.println(JSONUtil.parse(trxMap));
}
2)输入后果
{
"actionTraces":[
{
"actData":{
"ddc_id":6899,
"account":"ddcplatform1",
"business_type":2,
"func_name":"mint",
"fee":"0.0001 FEE",
"balance":"8.2350 FEE"
},
"actAccount":"ddccontract1",
"actName":"receiptpay"
},
{
"actData":{
"sender":"ddcplatform1",
"to":"ddcconsumer1",
"ddc_id":6899,
"ddc_uri":"https://bitnodes.io/0001",
"allowed":1,
"amount":10,
"business_type":2,
"ddc_name":"","ddc_symbol":""
},
"actAccount":"ddccontract1",
"actName":"receiptmint"
},
{
"actData":{
"sender":"ddcplatform1",
"from":"ddcconsumer1",
"to":"ddcconsumer1",
"amount":10,
"ddc_uri":"https://bitnodes.io/0001",
"business_type":2,
"memo":"memo0001",
"nonce":77,
"deadline":1671096761,
"signature":"SIG_K1_K5wAsgrAAoAyafBVXSXQQ8qSn6N7tY6XiyJ3wYvv1Bky3fZbYQJmuVw94wYnAqfqRfNZ7Zt7umMiSroArYSbu3vVbphZmh"
},
"actAccount":"ddccontract1",
"actName":"metamint"
}
],
"blockNum":8126659,
"blockTime":"2022-12-28T07:03:12.000",
"transactionId":"9d2e99de165568cd74ef4b779c73f4afa2085e023b1d80ccbd521237c9c1efa2"
}
(二)元交易批量生成
1、性能介绍
终端用户能够通过受权平台方调用该办法对 DDC 进行元交易批量平安生成,注:调用此接口所耗费的能量值和业务费对应的是平台方账户。
2、办法定义
1)SDK 办法定义:
DDC1155Service PushedTransaction metaSafeMintBatch(String sender, String from, String to, List<BigInteger> amounts, List<String> ddcURIs, String memo, BigInteger nonce, BigInteger deadline, String signature);
2)EOS 合约办法:
metamintbatc(name sender, name from,name to, std::vector<uint64_t> amounts, std::vector<std::string> ddc_uris, uint64_t business_type, std::string memo, uint64_t nonce, uint64_t deadline, signature signature);
3、输出参数
字段 | 字段名 | 类型 | 是否必传 | 备注 |
---|---|---|---|---|
sender | 调用者 | String | 是 | 调用者地址 |
from | 发送方账户 | String | 是 | |
to | 接收者账户 | String | 是 | |
amounts | DDC 数量列表 | List<BigInteger> | 是 | |
ddcURIs | DDC 资源标识符列表 | List<String> | 是 | |
memo | 附加数据 | String | 是 | |
nonce | Nonce 值 | BigInteger | 是 | |
deadline | 过期工夫 | BigInteger | 是 | |
signature | 签名值 | String | 是 |
4、输入参数
字段 | 字段名 | 类型 | 备注 |
---|---|---|---|
transactionId | 交易哈希 | String | |
processed | 执行信息 | Processed |
5、API 调用
1)测试用例
@Test
public void metaSafeMintBatch1155() {List<BigInteger> amounts = Arrays.asList(BigInteger.valueOf(20), BigInteger.valueOf(30));
List<String> ddcURIs = Arrays.asList("http://ddcUrl1", "http://ddcUrl2");
String memo = "memo0001";
BigInteger deadline = BigInteger.valueOf(1671096761);
DDC1155Service ddc1155Service = new DDC1155ServiceImpl();
BigInteger nonce = ddc1155Service.getNonce(accountList.get(2));
DDC1155MetaTransaction metaTransaction = new DDC1155MetaTransaction();
String digest = metaTransaction.getSafeMintBatchDigest(accountList.get(1), accountList.get(2), accountList.get(2), amounts, ddcURIs, memo, nonce, deadline);
String signature = metaTransaction.generateSignature(privateKey, digest.getBytes(StandardCharsets.UTF_8));
PushedTransaction pt = ddc1155Service.metaSafeMintBatch(accountList.get(1), accountList.get(2), accountList.get(2), amounts, ddcURIs, memo, nonce, deadline, signature);
Map<String, Object> trxMap = ChainUtil.getInstance().parseTrxResp(pt);
System.out.println(JSONUtil.parse(trxMap));
}
2)输入后果
{
"actionTraces":[
{
"actData":{
"ddc_id":6900,
"account":"ddcplatform1",
"business_type":2,
"func_name":"mintbatch",
"fee":"0.0001 FEE",
"balance":"8.2349 FEE"
},
"actAccount":"ddccontract1",
"actName":"receiptpay"
},
{
"actData":{
"sender":"ddcplatform1",
"to":"ddcconsumer1",
"ddc_id":6900,
"ddc_uri":"http://ddcUrl1",
"allowed":1,
"amount":20,
"business_type":2,
"ddc_name":"","ddc_symbol":""
},
"actAccount":"ddccontract1",
"actName":"receiptmint"
},
{
"actData":{
"ddc_id":6901,
"account":"ddcplatform1",
"business_type":2,
"func_name":"mintbatch",
"fee":"0.0001 FEE",
"balance":"8.2348 FEE"
},
"actAccount":"ddccontract1",
"actName":"receiptpay"
},
{
"actData":{
"sender":"ddcplatform1",
"to":"ddcconsumer1",
"ddc_id":6901,
"ddc_uri":"http://ddcUrl2",
"allowed":1,
"amount":30,
"business_type":2,
"ddc_name":"","ddc_symbol":""
},
"actAccount":"ddccontract1",
"actName":"receiptmint"
},
{
"actData":{
"sender":"ddcplatform1",
"from":"ddcconsumer1",
"to":"ddcconsumer1",
"amounts":[
20,
30
],
"ddc_uris":[
"http://ddcUrl1",
"http://ddcUrl2"
],
"business_type":2,
"memo":"memo0001",
"nonce":78,
"deadline":1671096761,
"signature":"SIG_K1_KfJAvnwbWXxzijNhZKsnLs4M1xHYYb3uABPho9VJcoHpQBbpGUphFXRpEAQJuhar8jzdxs4TTt1JY7giSRVuFKYD5XYBBN"
},
"actAccount":"ddccontract1",
"actName":"metamintbatc"
}
],
"blockNum":8127577,
"blockTime":"2022-12-28T07:10:51.000",
"transactionId":"75f44ef74a241e2e341d16056e6ee379b25cf1b73a51a942a244839a974da21c"
}
(三)元交易转移
1、性能介绍
DDC 拥有者或 DDC 受权者通过受权平台方调用该办法对 DDC 进行元交易转移,注:调用此接口所耗费的能量值和业务费对应的是平台方账户。
2、办法定义
1)SDK 办法定义:
DDC721Service PushedTransaction metaSafeTransferFrom(String sender, String from, String to, BigInteger ddcId, String memo, BigInteger nonce, BigInteger deadline, String signature);
DDC1155Service PushedTransaction metaSafeTransferFrom(String sender, String from, String to, BigInteger ddcId, BigInteger amount, String memo, BigInteger nonce, BigInteger deadline, String signature);
2)EOS 合约办法:
metatransfer(name sender, name from, name to, uint64_t ddc_id, uint64_t amount, std::string memo, uint64_t business_type, uint64_t nonce, uint64_t deadline, signature signature);
3、输出参数
字段 | 字段名 | 类型 | 是否必传 | 备注 |
---|---|---|---|---|
sender | 调用者 | String | 是 | 调用者地址 |
from | 发送方账户 | String | 是 | |
to | 接收者账户 | String | 是 | |
ddcId | DDC 惟一标识 | BigInteger | 是 | |
amount | DDC 数量 | BigInteger | 否 | DDC721 不传 |
memo | 附加数据 | String | 是 | |
nonce | Nonce 值 | BigInteger | 是 | |
deadline | 过期工夫 | BigInteger | 是 | |
signature | 签名值 | String | 是 |
4、输入参数
字段 | 字段名 | 类型 | 备注 |
---|---|---|---|
transactionId | 交易哈希 | String | |
processed | 执行信息 | Processed |
5、API 调用
1)测试用例(以 DDC1155 为例)
@Test
public void metaSafeTransferFrom1155() {BigInteger ddcId = BigInteger.valueOf(136);
BigInteger amount = BigInteger.valueOf(2);
String memo = "memo0001";
BigInteger deadline = BigInteger.valueOf(1671096761);
DDC1155Service ddc1155Service = new DDC1155ServiceImpl();
BigInteger nonce = ddc1155Service.getNonce(accountList.get(2));
DDC1155MetaTransaction metaTransaction = new DDC1155MetaTransaction();
String digest = metaTransaction.getSafeTransferFromDigest(accountList.get(1), accountList.get(2), accountList.get(2), ddcId, amount, memo, nonce, deadline);
String signature = metaTransaction.generateSignature(privateKey, digest.getBytes(StandardCharsets.UTF_8));
PushedTransaction pt = ddc1155Service.metaSafeTransferFrom(accountList.get(1), accountList.get(2), accountList.get(2), ddcId, amount, memo, nonce, deadline, signature);
Map<String, Object> trxMap = ChainUtil.getInstance().parseTrxResp(pt);
System.out.println(JSONUtil.parse(trxMap));
}
2)输入后果
{
"actionTraces":[
{
"actData":{
"ddc_id":136,
"account":"ddcplatform1",
"business_type":2,
"func_name":"transfer",
"fee":"0.0001 FEE",
"balance":"8.2347 FEE"
},
"actAccount":"ddccontract1",
"actName":"receiptpay"
},
{
"actData":{
"sender":"ddcplatform1",
"from":"ddcconsumer1",
"to":"ddcconsumer1",
"ddc_id":136,
"amount":2,
"memo":"memo0001",
"business_type":2,
"nonce":79,
"deadline":1671096761,
"signature":"SIG_K1_KkQvq6AnrCxS2hzdqYhsqJB3AtZeQW5RJfviSMGaBYgaHXdVAFdEzW8Q5nkQMd4k7LdWprSCKLmUM49JBFGtY9TrTv9hL4"
},
"actAccount":"ddccontract1",
"actName":"metatransfer"
}
],
"blockNum":8128554,
"blockTime":"2022-12-28T07:18:59.500",
"transactionId":"d26f43175c9b07ae3ace53122edc82ee704484168479672cccadf6ed6ea33818"
}
(四)元交易批量转移
1、性能介绍
DDC 拥有者或 DDC 受权者能够通过受权平台方调用该办法对 DDC 进行元交易批量转移,注:调用此接口所耗费的能量值和业务费对应的是平台方账户。
2、办法定义
1)SDK 办法定义:
DDC1155Service PushedTransaction metaSafeBatchTransferFrom(String sender, String from, String to, List<BigInteger> ddcIds, List<BigInteger> amounts, String memo, BigInteger nonce, BigInteger deadline, String signature);
2)EOS 合约办法:
metatransbat (name sender, name from, name to, std::vector<uint64_t> ddc_ids, std::vector<uint64_t> amounts, std::string memo, uint64_t business_type, uint64_t nonce, uint64_t deadline, signature signature);
3、输出参数
字段 | 字段名 | 类型 | 是否必传 | 备注 |
---|---|---|---|---|
sender | 调用者 | String | 是 | 调用者地址 |
from | 发送方账户 | String | 是 | |
to | 接收者账户 | String | 是 | |
ddcIds | DDC 惟一标识列表 | List<BigInteger> | 是 | |
amounts | DDC 数量列表 | List<BigInteger> | 是 | |
memo | 附加数据 | String | 是 | |
nonce | Nonce 值 | BigInteger | 是 | |
deadline | 过期工夫 | BigInteger | 是 | |
signature | 签名值 | String | 是 |
4、输入参数
字段 | 字段名 | 类型 | 备注 |
---|---|---|---|
transactionId | 交易哈希 | String | |
processed | 执行信息 | Processed |
5、API 调用
1)测试用例
@Test
public void metaSafeBatchTransferFrom1155() {List<BigInteger> ddcIds = Arrays.asList(BigInteger.valueOf(137), BigInteger.valueOf(138));
List<BigInteger> amounts = Arrays.asList(BigInteger.valueOf(2), BigInteger.valueOf(3));
String memo = "memo0001";
BigInteger deadline = BigInteger.valueOf(1671096761);
DDC1155Service ddc1155Service = new DDC1155ServiceImpl();
BigInteger nonce = ddc1155Service.getNonce(accountList.get(2));
DDC1155MetaTransaction metaTransaction = new DDC1155MetaTransaction();
String digest = metaTransaction.getSafeBatchTransferFromDigest(accountList.get(1), accountList.get(2), accountList.get(2), ddcIds, amounts, memo, nonce, deadline);
String signature = metaTransaction.generateSignature(privateKey, digest.getBytes(StandardCharsets.UTF_8));
PushedTransaction pt = ddc1155Service.metaSafeBatchTransferFrom(accountList.get(1), accountList.get(2), accountList.get(2), ddcIds, amounts, memo, nonce, deadline, signature);
Map<String, Object> trxMap = ChainUtil.getInstance().parseTrxResp(pt);
System.out.println(JSONUtil.parse(trxMap));
}
2)输入后果
{
"actionTraces":[
{
"actData":{
"ddc_id":137,
"account":"ddcplatform1",
"business_type":2,
"func_name":"batchtrans",
"fee":"0.0001 FEE",
"balance":"8.2346 FEE"
},
"actAccount":"ddccontract1",
"actName":"receiptpay"
},
{
"actData":{
"ddc_id":138,
"account":"ddcplatform1",
"business_type":2,
"func_name":"batchtrans",
"fee":"0.0001 FEE",
"balance":"8.2345 FEE"
},
"actAccount":"ddccontract1",
"actName":"receiptpay"
},
{
"actData":{
"sender":"ddcplatform1",
"from":"ddcconsumer1",
"to":"ddcconsumer1",
"ddc_ids":[
137,
138
],
"amounts":[
2,
3
],
"memo":"memo0001",
"business_type":2,
"nonce":80,
"deadline":1671096761,
"signature":"SIG_K1_KWTUkvmwpYiTK9jvZcrWSJSs9p9XnX2Br6odYv7fVzQ6qZmQrhfXXf5VEMAvrwLo9Ufs3pijh4u9JioT2wKwFFx5dF4dvW"
},
"actAccount":"ddccontract1",
"actName":"metatransbat"
}
],
"blockNum":8129207,
"blockTime":"2022-12-28T07:24:26.000",
"transactionId":"a4c2049569c305f094ffd6c568711796b8eb4df4e21b8b326077491844d6ca01"
}
(五)元交易销毁
1、性能介绍
DDC 拥有者或 DDC 受权者能够通过受权平台方调用该办法对 DDC 进行元交易销毁,注:调用此接口所耗费的能量值和业务费对应的是平台方账户。
2、办法定义
1)SDK 办法定义:
DDC721Service PushedTransaction metaBurn(String sender, String owner, BigInteger ddcId, BigInteger nonce, BigInteger deadline, String signature);
DDC1155Service PushedTransaction metaBurn(String sender, String owner, BigInteger ddcId, BigInteger nonce, BigInteger deadline, String signature);
2)EOS 合约办法:
metaburn(name sender, name owner, uint64_t ddc_id, uint64_t business_type, uint64_t nonce, uint64_t deadline, signature signature);
3、输出参数
字段 | 字段名 | 类型 | 是否必传 | 备注 |
---|---|---|---|---|
sender | 调用者 | String | 是 | 调用者地址 |
owner | 拥有者账户 | String | 是 | |
ddcId | DDC 惟一标识 | BigInteger | 是 | |
nonce | Nonce 值 | BigInteger | 是 | |
deadline | 过期工夫 | BigInteger | 是 | |
signature | 签名值 | String | 是 |
4、输入参数
字段 | 字段名 | 类型 | 备注 |
---|---|---|---|
transactionId | 交易哈希 | String | |
processed | 执行信息 | Processed |
5、API 调用
1)测试用例(以 DDC1155 为例)
@Test
public void metaBurn1155() {BigInteger ddcId = BigInteger.valueOf(139);
BigInteger deadline = BigInteger.valueOf(1671096761);
DDC1155Service ddc1155Service = new DDC1155ServiceImpl();
BigInteger nonce = ddc1155Service.getNonce(accountList.get(2));
DDC1155MetaTransaction metaTransaction = new DDC1155MetaTransaction();
String digest = metaTransaction.getBurnDigest(accountList.get(1), accountList.get(2), ddcId, nonce, deadline);
String signature = metaTransaction.generateSignature(privateKey, digest.getBytes(StandardCharsets.UTF_8));
PushedTransaction pt = ddc1155Service.metaBurn(accountList.get(1), accountList.get(2), ddcId, nonce, deadline, signature);
Map<String, Object> trxMap = ChainUtil.getInstance().parseTrxResp(pt);
System.out.println(JSONUtil.parse(trxMap));
}
2)输入后果
{
"actionTraces":[
{
"actData":{
"ddc_id":139,
"account":"ddcplatform1",
"business_type":2,
"func_name":"burn",
"fee":"0.0001 FEE",
"balance":"8.2343 FEE"
},
"actAccount":"ddccontract1",
"actName":"receiptpay"
},
{
"actData":{
"sender":"ddcplatform1",
"owner":"ddcconsumer1",
"ddc_id":139,
"business_type":2,
"nonce":82,
"deadline":1671096761,
"signature":"SIG_K1_Kk7xG8Ux1Nu7jjF4zx4p98BLb4cZHVxwTbTV1L9nxU4zXiaRQoeNGq4WDv33hdFZ3pGrLyrcK5XwSkPR7sn7vdm3hdi2yG"
},
"actAccount":"ddccontract1",
"actName":"metaburn"
}
],
"blockNum":8129841,
"blockTime":"2022-12-28T07:29:43.000",
"transactionId":"863711b5f8a4aa17ec167ecf073c62c4c2491754bed29064b1935c19bcf84929"
}
(六)元交易批量销毁
1、性能介绍
DDC 拥有者或 DDC 受权者能够通过受权平台方调用该办法对 DDC 进行元交易批量销毁,注:调用此接口所耗费的能量值和业务费对应的是平台方账户。
2、办法定义
1)SDK 办法定义:
DDC1155Service PushedTransaction metaBurnBatch(String sender, String owner, List<BigInteger> ddcIds, BigInteger nonce, BigInteger deadline, String signature);
2)EOS 合约办法:
metaburnbatc(name sender, name owner, std::vector<uint64_t> ddc_ids, uint64_t business_type, uint64_t nonce, uint64_t deadline, signature signature);
3、输出参数
字段 | 字段名 | 类型 | 是否必传 | 备注 |
---|---|---|---|---|
sender | 调用者 | String | 是 | 调用者地址 |
owner | 拥有者账户 | String | 是 | |
ddcIds | DDC 惟一标识列表 | List<BigInteger> | 是 | |
nonce | Nonce 值 | BigInteger | 是 | |
deadline | 过期工夫 | BigInteger | 是 | |
signature | 签名值 | String | 是 |
4、输入参数
字段 | 字段名 | 类型 | 备注 |
---|---|---|---|
transactionId | 交易哈希 | String | |
processed | 执行信息 | Processed |
5、API 调用
1)测试用例
@Test
public void metaBurnBatch1155() {List<BigInteger> ddcIds = Arrays.asList(BigInteger.valueOf(137), BigInteger.valueOf(138));
BigInteger deadline = BigInteger.valueOf(1671096761);
DDC1155Service ddc1155Service = new DDC1155ServiceImpl();
BigInteger nonce = ddc1155Service.getNonce(accountList.get(2));
DDC1155MetaTransaction metaTransaction = new DDC1155MetaTransaction();
String digest = metaTransaction.getBurnBatchDigest(accountList.get(1), accountList.get(2), ddcIds, nonce, deadline);
String signature = metaTransaction.generateSignature(privateKey, digest.getBytes(StandardCharsets.UTF_8));
PushedTransaction pt = ddc1155Service.metaBurnBatch(accountList.get(1), accountList.get(2), ddcIds, nonce, deadline, signature);
Map<String, Object> trxMap = ChainUtil.getInstance().parseTrxResp(pt);
System.out.println(JSONUtil.parse(trxMap));
}
2)输入后果
{
"actionTraces":[
{
"actData":{
"ddc_id":137,
"account":"ddcplatform1",
"business_type":2,
"func_name":"burnbatch",
"fee":"0.0001 FEE",
"balance":"8.2342 FEE"
},
"actAccount":"ddccontract1",
"actName":"receiptpay"
},
{
"actData":{
"ddc_id":138,
"account":"ddcplatform1",
"business_type":2,
"func_name":"burnbatch",
"fee":"0.0001 FEE",
"balance":"8.2341 FEE"
},
"actAccount":"ddccontract1",
"actName":"receiptpay"
},
{
"actData":{
"sender":"ddcplatform1",
"owner":"ddcconsumer1",
"ddc_ids":[
137,
138
],
"business_type":2,
"nonce":83,
"deadline":1671096761,
"signature":"SIG_K1_K4TC8gPC3iLQcrrKYRS7kgsNKX2xh6AB8CSyaRyN6fYfiAow3YMctBGg2z9pyS7RPuXmidn6GVapJ4k7scMxRFJPzAFc8X"
},
"actAccount":"ddccontract1",
"actName":"metaburnbatc"
}
],
"blockNum":8130284,
"blockTime":"2022-12-28T07:33:24.500",
"transactionId":"9352f902710cf44133729b1730565c95a5900d7d51f95bef1f043f2de42bae71"
}