用户中心
SDK获取

SDK适用于区块链账户注册/绑定、资产发行、资产交易、查看资产/账户信息等功能。

开发语言 下载版本 环境要求
Java版资源 SDK1.6.0 适用于Java语言
SDK集成及示例

1、SDK已经对加签验签逻辑做了封装,使用SDK可直接调用API。

2、SDK包说明

文件名 文件说明
bubi4j-sdk-1.6.0.jar 布比区块链资产类SDK文件jar
bubi4j-sdk-1.6.0-sources.jar 布比区块链资产类SDK源码文件jar
commons-lang3-3.4.jar SDK依赖的通用基础jar
commons-logging-1.0.4.jar SDK依赖的日志jar
fastjson-1.2.7.jar SDK依赖的json解析工具jar
hamcrest-core-1.3.jar junit依赖的Hamcrest框架jar
junit-4.12.jar SDK依赖的单元测试框架jar
org.apache.servicemix.bundles.commons-httpclient-3.1_7.jar SDK依赖的http协议客户端编程工具文件jar
org.apache.servicemix.bundles.commons-codec-1.3_2.jar SDK依赖的编码方法工具类jar
数字资产SDK用示例

SDK接口授权调用示例

String url = "https://api.bubidev.cn/";
String appid = "您的APP ID";
String appkey = "您的APP 密钥";
BubiServiceFactory factory = BubiServiceFactory.getInstance(url, appid, appkey);
//获取token
String accessToken = factory.getOAuthService().getAccessToken();

区块链账户注册

String url = "https://api.bubidev.cn/";
String appid = "您的APP ID";
String appkey = "您的APP 密钥";
BubiServiceFactory factory = BubiServiceFactory.getInstance(url, appid, appkey);
//获取token
String accessToken = factory.getOAuthService().getAccessToken();

//待注册布比账户名
String userName = "b121045";
//待注册布比账户密码
String password = "qaz12345678";
//接口调用凭据号,必须在商户系统里保证唯一
String tradeNo = "100000982014120351565179";

//把请求参数组装成集合
Map sParaTemp = new HashMap();
sParaTemp.put("user_name", userName);
sParaTemp.put("password", password);
sParaTemp.put("trade_no", tradeNo);

//请求布比区块链注册接口
Account account = factory.getAccountService(accessToken);
String result = account.registerBubiAccount(JSON.toJSONString(sParaTemp));
System.out.println(result);

资产发行

String url = "https://api.bubidev.cn/";
String appid = "您的APP ID";
String appkey = "您的APP 密钥";
BubiServiceFactory factory = BubiServiceFactory.getInstance(url, appid, appkey);
//获取token
String accessToken = factory.getOAuthService().getAccessToken();

//[必填] 资产发行商布比地址 即bubi_id
String assetIssuer = "bubiV8i68LTsZS2aFn57G16KpwkrdXRNijnfWFam";
//[必填] 待发行资产名称
String assetName = "花牛贝";
//[必填] 待发行资产单位
String assetUnit = "贝";
//[必填] 待发行资产数量
String assetAmount = "10000";
//[必填] 资产发行商账号密码
String accPwd = "qaz12345678";
//[可选] 资产说明,如,资产描述或摘要
String metadata = "";
//[必填]接口调用凭据号,必须在商户系统里保证唯一
String tradeNo = "10000098201412054434746";
//请求资产发行接口
Asset asset = factory.getAssetService(accessToken);
String result = asset.issue(assetIssuer,accPwd,tradeNo,assetName,assetUnit,assetAmount,metadata);
System.out.println(result);

资产转移

String url = "https://api.bubidev.cn/";
String appid = "您的APP ID";
String appkey = "您的APP 密钥";
BubiServiceFactory factory = BubiServiceFactory.getInstance(url, appid, appkey);
//获取token
String accessToken = factory.getOAuthService().getAccessToken();

//获取token
String token = factory.getOAuthService().getAccessToken();
//[必填] 随机字符串
String currentString = GUIDUtil.createNewGuid(GUIDUtil.AfterMD5);
//[必填] 资产转出方的账户密码
String accPwd = "qaz12345678";
//[必填] 接口调用凭据号,必须在商户系统里保证唯一
String tradeNo = "3323";
//[必填] 资产CODE,转出方给转入方转让的资产标识(全网唯一)
String assetCode = "2UX4xvQ4aXNRFwvdZbE6rXP9uc1WsxBbvXu7nKp1qNABbiDCCj6toYJxBpCXqjNcvCjkAo8GnWNxL1Sfr
fQ77RLCKBTortzwaTkDgDDsGiXmMAEeJJWZkrqxZq92AjA7uxToPkYXVosxfdcP";
//[必填] 资产转移数量
String assetAmount = "1";
//[必填] 资产转出方
String fromBubiId = "bubiV8i2XC8gweN36NjUpxjGpL2gMARTh4LjSRYj";
//[必填] 资产转入方
String toBubiId = "bubiV8i1tspT5DrpfNhcqXPZ5gxurAVMbN6PSf7j";
//请求资产转移接口
Asset asset = factory.getAssetService(accessToken);
String result = asset.send(currentString, accPwd, tradeNo, assetCode, assetAmount, fromBubiId, toBubiId);
System.out.println(result);