数字资产
<h3>API清单</h3>
<p>数字资产服务由以下API组成,接入商户可以按照自己的业务自由组合使用</p>
<p><a href="#注册链上ID">注册链上ID</a>
<a href="#判断链上ID是否存在">判断链上ID是否存在</a>
<a href="#判断链上ID和密码是否匹配">判断链上ID和密码是否匹配</a>
<a href="#资产上链">资产上链</a>
<a href="#资产Uri设置">资产Uri设置</a>
<a href="#资产转移">资产转移</a>
<a href="#资产信息">资产信息</a>
<a href="#资产发行">资产发行</a>
<a href="#凭证转移">凭证转移</a>
<a href="#凭证所有者查询">凭证所有者查询</a>
<a href="#资产凭证数量查询">资产凭证数量查询</a></p>
<hr />
<h3>API对接说明</h3>
<h4>请求格式</h4>
<p>所有API的请求格式均为:x-www-form-urlencoded</p>
<h4>公共请求参数</h4>
<p>所有API需要传递以下参数</p>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>appId</td>
<td>String</td>
<td>是</td>
<td>服务商分配的唯一标识</td>
</tr>
<tr>
<td>timestamp</td>
<td>Long</td>
<td>是</td>
<td>当前时间的毫秒数</td>
</tr>
<tr>
<td>sign</td>
<td>String</td>
<td>是</td>
<td>签名,见签名算法说明</td>
</tr>
<tr>
<td>...</td>
<td>...</td>
<td>...</td>
<td>各API具体参数,详见各API请求参数说明</td>
</tr>
</tbody>
</table>
<blockquote>
<p>调用各API时需要将公共参数和各API的具体参数一并传入</p>
</blockquote>
<h4>签名算法</h4>
<pre><code>sign = sha256(appId + appSecret + timestamp)</code></pre>
<p>用服务商分配的 <strong>appId</strong>、服务商分配的 <strong>appSecret</strong>,当前时间毫秒数 <strong>timestamp</strong>,按上述顺序拼接成字符串,再进行 <strong>sha256</strong> 哈希得到。如下:</p>
<pre><code class="language-java">String appId = "xyzxy2121zxyz";
String timestamp = "1555378976238";
String appSecret = "efcefcef1121cefcefc1212121";
String str = appId + appSecret + timestamp;
String sign = sha256(str);</code></pre>
<h4>公共返回说明</h4>
<p>所有API的返回格式如下</p>
<pre><code>// 成功
{
"code": 200, // 详见code返回码说明
"msg": "成功", // code对应的描述
"charge": true, // 计费标志
"taskNo": "69564903663951243279", // 本次唯一请求号
"data": { // 具体API的返回数据,详见各API的返回说明
}
}
// 失败
{
"code": 400,
"msg": "",
"charge": false
}</code></pre>
<h4>公共code返回码说明</h4>
<table>
<thead>
<tr>
<th>code</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>200</td>
<td>成功(计费)</td>
</tr>
<tr>
<td>400</td>
<td>参数错误</td>
</tr>
<tr>
<td>404</td>
<td>接口地址不正确</td>
</tr>
<tr>
<td>500</td>
<td>系统维护,请稍候再试</td>
</tr>
<tr>
<td>601</td>
<td>接口未开通</td>
</tr>
<tr>
<td>602</td>
<td>账号停用</td>
</tr>
<tr>
<td>603</td>
<td>余额不足请充值</td>
</tr>
<tr>
<td>604</td>
<td>接口停用</td>
</tr>
<tr>
<td>702</td>
<td>智能合约调用错误</td>
</tr>
<tr>
<td>999</td>
<td>其他,以实际返回为准</td>
</tr>
</tbody>
</table>
<hr />
<p><a name="注册链上ID"></a></p>
<h3>注册链上ID</h3>
<p>商户为C端用户注册链上ID,用于绑定数字资产,相当于钱包。
商户可根据需求,决定是否为每一个C端用户注册链上ID。为保证C端用户对资产的所有权,建议为每个C端用户注册一个链上ID。</p>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/digital-assets/user/register</code></p>
<h4>请求参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>userId</td>
<td>String</td>
<td>否</td>
<td>用户链上ID,类似于钱包地址,未填时会生成随机唯一ID</td>
</tr>
<tr>
<td>pwd</td>
<td>String</td>
<td>是</td>
<td>密码,推荐使用Hash而不是明文密码,建议商户对C端用户输入密码进行Hash混淆</td>
</tr>
</tbody>
</table>
<blockquote>
<p>上表仅列出本API具体的请求参数,实际调用时需要和公共参数一并传入</p>
</blockquote>
<h4>请求方式</h4>
<ul>
<li>POST</li>
</ul>
<h4>返回说明</h4>
<pre><code>{
"code": 200,
"msg": "成功",
"charge": true,
"taskNo": "69564903663951243279",
"data": {
"userId": "testusern", // 用户链上ID
"txid": "3ed5cd1ba85dd8c1c2fa28f258e282d45822524618e8694e6fdbd300b50366bf" // 交易Hash,可用于在区块链浏览器中查询交易记录
}
}</code></pre>
<hr />
<p><a name="判断链上ID是否存在"></a></p>
<h3>判断链上ID是否存在</h3>
<p>检查链上ID是否已经存在,因为链上ID具有唯一性。</p>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/digital-assets/user/exist-check</code></p>
<h4>请求参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>userId</td>
<td>String</td>
<td>是</td>
<td>用户链上ID</td>
</tr>
</tbody>
</table>
<blockquote>
<p>上表仅列出本API具体的请求参数,实际调用时需要和公共参数一并传入</p>
</blockquote>
<h4>请求方式</h4>
<ul>
<li>POST</li>
</ul>
<h4>返回说明</h4>
<pre><code>{
"code": 200,
"msg": "成功",
"charge": true,
"taskNo": "69564903663951243279",
"data": {
"existed": true // 已经存在为true,反之为false
}
}</code></pre>
<hr />
<p><a name="判断链上ID和密码是否匹配"></a></p>
<h3>判断链上ID和密码是否匹配</h3>
<p>检查链上ID,与输入的密码是否匹配,可用于验证用户是否为该链上ID的所有者</p>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/digital-assets/user/pwd-check</code></p>
<h4>请求参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>userId</td>
<td>String</td>
<td>是</td>
<td>用户链上ID</td>
</tr>
<tr>
<td>pwd</td>
<td>String</td>
<td>是</td>
<td>密码</td>
</tr>
</tbody>
</table>
<blockquote>
<p>上表仅列出本API具体的请求参数,实际调用时需要和公共参数一并传入</p>
</blockquote>
<h4>请求方式</h4>
<ul>
<li>POST</li>
</ul>
<h4>返回说明</h4>
<pre><code>{
"code": 200,
"msg": "成功",
"charge": true,
"taskNo": "69564903663951243279",
"data": {
"match": true //匹配为true,反之为false
}
}</code></pre>
<hr />
<p><a name="资产上链"></a></p>
<h3>资产上链</h3>
<p>将数字资产的创作、类型和所有者等信息进行上链,同时确定资产的最大发行量。
资产所有者,至少拥有一个链上ID,用来绑定资产,以便后续的发行。</p>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/digital-assets/assets/deploy</code></p>
<h4>请求参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>assetId</td>
<td>String</td>
<td>否</td>
<td>唯一链上资产ID,为十进制数字符串; 未填时会生成随机唯一ID</td>
</tr>
<tr>
<td>name</td>
<td>String</td>
<td>是</td>
<td>资产名称</td>
</tr>
<tr>
<td>creator</td>
<td>String</td>
<td>是</td>
<td>数字资产创作者,可使用链上ID或自定义内容</td>
</tr>
<tr>
<td>owner</td>
<td>String</td>
<td>是</td>
<td>数字资产项目方或所有者的链上ID,后续发行资产时需要</td>
</tr>
<tr>
<td>category</td>
<td>String</td>
<td>是</td>
<td>资产类别,B端用户可自定义</td>
</tr>
<tr>
<td>description</td>
<td>String</td>
<td>是</td>
<td>资产描述,可自定义内容</td>
</tr>
<tr>
<td>maxSupply</td>
<td>Number</td>
<td>是</td>
<td>资产的最大发行量,后续可销售的份数</td>
</tr>
<tr>
<td>uri</td>
<td>String</td>
<td>否</td>
<td>资产的meta数据uri链接</td>
</tr>
</tbody>
</table>
<blockquote>
<p>上表仅列出本API具体的请求参数,实际调用时需要和公共参数一并传入</p>
</blockquote>
<h4>请求方式</h4>
<ul>
<li>POST</li>
</ul>
<h4>返回说明</h4>
<pre><code>{
"code": 200,
"msg": "成功",
"charge": true,
"taskNo": "69564903663951243279",
"data": {
"assetId": "1024", // 唯一链上资产ID
"txid": "696b4b3e9a779476a9e5eeda5bf17186b318a86a634b38eebcb992c2cd6cd95d" // 交易Hash,可用于在区块链浏览器中查询交易记录
}
}</code></pre>
<hr />
<p><a name="资产Uri设置"></a></p>
<h3>资产Uri设置</h3>
<p>设置资产的uri,为包含资产元信息链接</p>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/digital-assets/assets/uri-setup</code></p>
<h4>请求参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>assetId</td>
<td>String</td>
<td>是</td>
<td>唯一链上资产ID</td>
</tr>
<tr>
<td>pwd</td>
<td>String</td>
<td>是</td>
<td>资产所有者即owner的pwd,与owner的pwd匹配才能设置</td>
</tr>
<tr>
<td>uri</td>
<td>String</td>
<td>是</td>
<td>资产的uri链接</td>
</tr>
</tbody>
</table>
<blockquote>
<p>上表仅列出本API具体的请求参数,实际调用时需要和公共参数一并传入</p>
</blockquote>
<h4>请求方式</h4>
<ul>
<li>POST</li>
</ul>
<h4>返回说明</h4>
<pre><code>{
"code": 200,
"msg": "成功",
"charge": true,
"taskNo": "69564903663951243279",
"data": {
"txid": "2f846001a5456a7055bc4f247b6371e6d2bb06b94c2054ef262d0a976c615640"
}
}</code></pre>
<hr />
<p><a name="资产转移"></a></p>
<h3>资产转移</h3>
<p>转移数字资产的所有权,所有权可用于资产的发行</p>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/digital-assets/assets/transfer</code></p>
<h4>请求参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>assetId</td>
<td>String</td>
<td>是</td>
<td>唯一链上资产ID</td>
</tr>
<tr>
<td>pwd</td>
<td>String</td>
<td>是</td>
<td>资产所有者即owner的pwd,与owner的pwd匹配才能进行资产发行</td>
</tr>
<tr>
<td>to</td>
<td>String</td>
<td>是</td>
<td>资产接收者的链上ID</td>
</tr>
</tbody>
</table>
<blockquote>
<p>上表仅列出本API具体的请求参数,实际调用时需要和公共参数一并传入</p>
</blockquote>
<h4>请求方式</h4>
<ul>
<li>POST</li>
</ul>
<h4>返回说明</h4>
<pre><code>{
"code": 200,
"msg": "成功",
"charge": true,
"taskNo": "69564903663951243279",
"data": {
"txid": "2f846001a5456a7055bc4f247b6371e6d2bb06b94c2054ef262d0a976c615640"
}
}</code></pre>
<hr />
<p><a name="资产信息"></a></p>
<h3>资产信息</h3>
<p>查询数字资产的各类信息,以及发行量等。</p>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/digital-assets/assets/info</code></p>
<h4>请求参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>assetId</td>
<td>String</td>
<td>是</td>
<td>唯一链上资产ID</td>
</tr>
</tbody>
</table>
<blockquote>
<p>上表仅列出本API具体的请求参数,实际调用时需要和公共参数一并传入</p>
</blockquote>
<h4>请求方式</h4>
<ul>
<li>GET/POST</li>
</ul>
<h4>返回说明</h4>
<pre><code>{
"code": 200,
"msg": "成功",
"charge": true,
"taskNo": "69564903663951243279",
"data": {
"assetId": "1024", //
"name": "1024号demo", // 资产名称
"creator": "Tom", // 数字资产创作者
"owner": "testuser1", // 数字资产所有者的链上ID
"category": "Profile", // 资产类别
"description": "This is a demo.", // 资产描述
"supply": "1", // 资产的当前的流通量或发行量
"maxSupply": "10000" // 资产的最大发行量
"uri": "" // 资产的meta数据uri链接
}
}</code></pre>
<hr />
<p><a name="资产发行"></a></p>
<h3>资产发行</h3>
<p>发行已上链的数字资产,为每份数字资产的购买者生成唯一凭证Token</p>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/digital-assets/token/mint</code></p>
<h4>请求参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>assetId</td>
<td>String</td>
<td>是</td>
<td>唯一链上资产ID,为十进制数字符串</td>
</tr>
<tr>
<td>pwd</td>
<td>String</td>
<td>是</td>
<td>资产所有者即owner的pwd,与owner的pwd匹配才能进行资产发行</td>
</tr>
<tr>
<td>to</td>
<td>String</td>
<td>是</td>
<td>数字资产购买者的链上ID</td>
</tr>
</tbody>
</table>
<blockquote>
<p>上表仅列出本API具体的请求参数,实际调用时需要和公共参数一并传入</p>
</blockquote>
<h4>请求方式</h4>
<ul>
<li>POST</li>
</ul>
<h4>返回说明</h4>
<pre><code>{
"code": 200,
"msg": "成功",
"charge": true,
"taskNo": "69564903663951243279",
"data": {
"tokenId":"94355566122148437436989075126255650048634313250026422190369154253956935676064", // 唯一链上资产购买凭证ID,用于后续的转赠
"txid": "b1515f4af05bd726c00f338139d9514a57defd0a62a023741ff1806c010e6797" // 交易Hash,可用于在区块链浏览器中查询交易记录
}
}</code></pre>
<hr />
<p><a name="凭证转移"></a></p>
<h3>凭证转移</h3>
<p>转移数字资产凭证Token</p>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/digital-assets/token/transfer</code></p>
<h4>请求参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>tokenId</td>
<td>String</td>
<td>是</td>
<td>唯一链上资产购买凭证ID</td>
</tr>
<tr>
<td>from</td>
<td>String</td>
<td>是</td>
<td>资产凭证所有者的链上ID</td>
</tr>
<tr>
<td>pwd</td>
<td>String</td>
<td>是</td>
<td>资产凭证所有者的pwd,即from对应的pwd</td>
</tr>
<tr>
<td>to</td>
<td>String</td>
<td>是</td>
<td>资产凭证接收者的链上ID</td>
</tr>
</tbody>
</table>
<blockquote>
<p>上表仅列出本API具体的请求参数,实际调用时需要和公共参数一并传入</p>
</blockquote>
<h4>请求方式</h4>
<ul>
<li>POST</li>
</ul>
<h4>返回说明</h4>
<pre><code>{
"code": 200,
"msg": "成功",
"charge": true,
"taskNo": "69564903663951243279",
"data": {
"txid": "93b388ae1adfc7c98f9eb6df77ca64dbf51461513481def99e0499761d9c0353" // 交易Hash,可用于在区块链浏览器中查询交易记录
}
}</code></pre>
<hr />
<p><a name="凭证所有者查询"></a></p>
<h3>凭证所有者查询</h3>
<p>查询购买凭证的所有者,可用于确权</p>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/digital-assets/token/owner</code></p>
<h4>请求参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>tokenId</td>
<td>String</td>
<td>是</td>
<td>唯一链上资产购买凭证ID</td>
</tr>
</tbody>
</table>
<blockquote>
<p>上表仅列出本API具体的请求参数,实际调用时需要和公共参数一并传入</p>
</blockquote>
<h4>请求方式</h4>
<ul>
<li>GET/POST</li>
</ul>
<h4>返回说明</h4>
<pre><code>{
"code": 200,
"msg": "成功",
"charge": true,
"taskNo": "69564903663951243279",
"data": {
"owner": "testuser1" // 资产购买凭证ID的所有者
}
}</code></pre>
<hr />
<p><a name="资产凭证数量查询"></a></p>
<h3>资产凭证数量查询</h3>
<p>可查询指定数字资产及账号的凭证数量,即购买份数</p>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/digital-assets/assets/balance</code></p>
<h4>请求参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>assetId</td>
<td>String</td>
<td>是</td>
<td>唯一链上资产ID</td>
</tr>
<tr>
<td>userId</td>
<td>String</td>
<td>是</td>
<td>指定用户的唯一链上ID</td>
</tr>
</tbody>
</table>
<blockquote>
<p>上表仅列出本API具体的请求参数,实际调用时需要和公共参数一并传入</p>
</blockquote>
<h4>请求方式</h4>
<ul>
<li>GET/POST</li>
</ul>
<h4>返回说明</h4>
<pre><code>{
"code": 200,
"msg": "成功",
"charge": true,
"taskNo": "69564903663951243279",
"data": {
"balance": 1 // 资产购买凭证数量,即购买的指定数字资产的份数
}
}</code></pre>