Overview
This document describes how to use the FT API, including::
• Preparation
• Execution order
Java ToolChainClient
If the client uses the Java programming language for development, VeChain has provided ToolChainClient sdk to help the client develop server-side applications more easily. Just add the following dependency in Java Maven. Other package management tools are available here
<!-- https://mvnrepository.com/artifact/com.vechain/toolchainclient -->
<dependency>
<groupId>com.vechain</groupId>
<artifactId>toolchainclient</artifactId>
<version>0.1.5</version>
</dependency>
The example in the sample code is for reference only. The client needs to use its own UID, UID of administrator account, etc.
Preparation
Access permission
Before starting, developers need to get appid and appkey which requires the administrator to log in to the console and apply in Developer Center->Server Application, each account can apply for up to 10 pairs of access rights.
Please use the administrator account to log in to the system, click Developer Center->Server Application, copy appid and appkey.
Access token
The access token is used by the VeChain ToolChain®️ back-end server to authenticate the client. Therefore, before calling the VeChain ToolChain®️ api, the client must call the "get token" api to get the access token. The token expires every 24 hours. When using ToolChainClient, you can use appid and appkey to create a new VeChain ToolChain®️ client, where "aa" refers to the application source that calls the api request. For each client application, VeChain ToolChain®️ recommends using a different source, which will make it easier to manage access token.
SDK Example:
ToolChainClient toolChainClient = new ToolChainClient(appid,appkey,"aa");
UID of administrator account
The UID will be used to mint token and toggle mint status of smart contract.
Log in to the system with an administrator account, and click Developer Center-> Business Contract in turn. Owner UID is the UID of the administrator account.
Execution order
The execution sequence is to describe how to use the FT interface, and gives the sample code of ToolChainClient. Customers can follow this sequential process and successfully use assets.
The execution sequence is as follows:
Create account
When the client calls to create account, the escrow account created in ToolChain consists of two parts: UID and wallet address. The address is derived from UID, and they are same.
There are 2 interfaces for creating accounts:
- Create account
- Create account in batches
Create account
SDK Example:
CreateUserRequest createUserRequest = new CreateUserRequest();
logger.debug("0.2 createUserRequest: {}", createUserRequest);
CreateUserResponse createUserResponse = (CreateUserResponse) toolChainClient.execute(createUserRequest);
while (true) {
Thread.sleep(10000);
logger.debug("0.2 createUserResponse: {}", createUserResponse);
if (createUserResponse.getData() != null && createUserResponse.getData().getOrderStatus().equals(OrderStatusEnum.SUCCESS.getStatus())) {
uids.add(createUserResponse.getData().getUid());
addresses.add(createUserResponse.getData().getAddress());
break;
}
createUserResponse = (CreateUserResponse) toolChainClient.execute(createUserRequest);
}
Response Example:
{
"code": 1,
"data":
{
"address": "0x3f3378256faed5efb3bd517849bfcc0464ea55c4",
"orderStatus": "SUCCESS",
"requestNo": "1596191148934",
"uid": "0xcc2e586c8c7b27f26628fc00b08fe6e94fd106d69135d3df27766b6e5d4d615f"
}
}
Create account in batches
SDK Example:
CreateBatchUserRequest createBatchUserRequest = new CreateBatchUserRequest();
createBatchUserRequest.setQuantity(5);
CreateBatchUserResponse createBatchUserResponse = toolChainClient.execute(createBatchUserRequest);
while (true) {
logger.debug("2.1 {}",createBatchUserResponse);
if(createBatchUserResponse.getData() != null && createBatchUserResponse.getData().getOrderStatus().equals(OrderStatusEnum.SUCCESS.getStatus())){
for(CreateBatchUserRespData.UsersBean usersBean: createBatchUserResponse.getData().getUsers()) {
uids.add(usersBean.getUid());
addresses.add(usersBean.getAddress());
}
break;
}
Thread.sleep(10000);
createBatchUserResponse = toolChainClient.execute(createBatchUserRequest);
}
Response Example:
{
"code": 1,
"data":
{
"orderStatus": "SUCCESS",
"users": [
{
"address": "0xe2d19cdaa16f6f50b869f13910cc5b80df4b8ce4",
"uid": "0x6dc41339f4d7ba74a56d33df59490f64f2a3f1eab5a6c18560e5c671739f9a83"
},
{
"address": "0x986912fb961fe463c4a91cced42c9e95c1be2cf0",
"uid": "0x9f49177401ce609844bb45dc750877a841424d38e45c3f36801de9ebe0ab134a"
},
{
"address": "0x7b231ced8c0680a52bd1993bb630742b8bb2aa3c",
"uid": "0x77d9933334885b8d888b02db6e95bd59a5c61aabb5ae978a4b2975967c329317"
},
{
"address": "0x7b94e5df4b95a2482cce4553ef3c68d0595ebfc3",
"uid": "0x84f83208597e4afd64a553894f0f5172c2ad81a5e1691f8ef6761e7a65f54e91"
},
{
"address": "0x9a03b4aa0cf61f9ab273cbe0cbc9ff74b6a0fb89",
"uid": "0x0299adb16d406400ee46f1f245118efce295605f26b44ba9f57f23e23908a70a"
}]
}
}
Mint token
There are 2 interfaces for minting tokens:
- Mint token to account
- Mint token to address
In both mint request, we support batch mint, which means in one request, client can put multiple vid&owner. This will increase the efficiency to mint token.
Mint token to account
SDK Example:
VIP180TransferResponse vip180TransferResponse;
String requestNo = String.valueOf(System.currentTimeMillis());
VIP180MintToUIDRequest vip180MintToUIDRequest = new VIP180MintToUIDRequest();
vip180MintToUIDRequest.setTokenContractAddress(contractAddress180);
vip180MintToUIDRequest.setRequestNo(requestNo);
vip180MintToUIDRequest.setOwnerUID(ownerUID);
List < VIP180MintToUIDRequestItem > lists = new ArrayList < > ();
VIP180MintToUIDRequestItem vip180MintToUIDRequestItem = new VIP180MintToUIDRequestItem();
vip180MintToUIDRequestItem.setToUID(uid_add);
vip180MintToUIDRequestItem.setAmount(amount);
lists.add(vip180MintToUIDRequestItem);
vip180MintToUIDRequest.setList(lists);
logger.debug("mint Token UID request: {}", JSONObject.toJSONString(vip180MintToUIDRequest));
vip180TransferResponse = toolChainClient.execute(vip180MintToUIDRequest);
while (true) {
logger.debug("1.1response: {}", vip180TransferResponse);
Thread.sleep(20000);
if (vip180TransferResponse.getData() != null) {
if (vip180TransferResponse.getData().getOrderStatus().equals(OrderStatusEnum.SUCCESS.getStatus())) {
logger.debug("mint token to uid: {} with {} success", uid_add, amount);
break;
} else if (vip180TransferResponse.getData().getOrderStatus().equals(OrderStatusEnum.FAIL.getStatus())) {
logger.debug("issue 1 token fail");
break;
}
}
vip180TransferResponse = toolChainClient.execute(vip180MintToUIDRequest);
}
Response Example:
{
"data":
{
"requestNo": "1596795734525",
"orderStatus": "SUCCESS",
"list": [
{
"amount": "0x1",
"clauseIndex": 0,
"txID": "0x58e7e3e5f973e487dc0b8c0c4afe33c6253d07e36305f4489749ffd790dc1a19",
"txStatus": "SUCCESS"
}]
},
"code": 1,
"message": "success"
}
Mint token to address
SDK Example:
VIP180TransferResponse vip180TransferResponse;
String requestNo = String.valueOf(System.currentTimeMillis());
VIP180MintToAddressRequest vip180MintToAddressRequest = new VIP180MintToAddressRequest();
vip180MintToAddressRequest.setTokenContractAddress(contractAddress180);
vip180MintToAddressRequest.setRequestNo(requestNo);
vip180MintToAddressRequest.setOwnerUID(ownerUID);
List<VIP180MintToAddressRequestItem> lists = new ArrayList<>()
VIP180MintToAddressRequestItem vip180MintToAddressRequestItem = new VIP180MintToAddressRequestItem();
vip180MintToAddressRequestItem.setToAddress(uid_add);
vip180MintToAddressRequestItem.setAmount(amount);
lists.add(vip180MintToAddressRequestItem);
vip180MintToAddressRequest.setList(lists);
logger.debug("mint Token address request: {}", JSONObject.toJSONString(vip180MintToAddressRequest));
vip180TransferResponse = toolChainClient.execute(vip180MintToAddressRequest);
logger.debug("{}", vip180TransferResponse);
while (true) {
logger.debug("1.1response: {}", vip180TransferResponse);
Thread.sleep(20000);
if (vip180TransferResponse.getData() != null) {
if (vip180TransferResponse.getData().getOrderStatus().equals(OrderStatusEnum.SUCCESS.getStatus())) {
logger.debug("mint token to address: {} with {} success", uid_add, amount);
break;
} else if (vip180TransferResponse.getData().getOrderStatus().equals(OrderStatusEnum.FAIL.getStatus())) {
logger.debug("issue 1 token fail");
break;
}
}
vip180TransferResponse = toolChainClient.execute(vip180MintToAddressRequest);
}
Response Example:
{
"data":
{
"requestNo": "1596695520622",
"orderStatus": "SUCCESS",
"list": [
{
"amount": "0x1",
"clauseIndex": 0,
"txID": "0x7500ce75601a81f01a5d2965dab299b12d7689d926b6f0952eeca3735963f9d5",
"txStatus": "SUCCESS"
}]
},
"code": 1,
"message": "success"
}
Transfer token to account
There are 2 interfaces for transferring tokens:
- Transfer token to account
- Transfer token to address
Transfer token to account
SDK Example:
String requestNo = new Date().toString();
VIP180TransferToUIDRequest vip180TransferToUIDRequest = new VIP180TransferToUIDRequest();
vip180TransferToUIDRequest.setTokenContractAddress(contractAddress180);
vip180TransferToUIDRequest.setRequestNo(requestNo);
vip180TransferToUIDRequest.setFromUID(from);
List < VIP180TransferToUIDRequestItem > lists = new ArrayList < > ();
VIP180TransferToUIDRequestItem vip180TransferToUIDRequestItem = new VIP180TransferToUIDRequestItem();
vip180TransferToUIDRequestItem.setToUID(to);
vip180TransferToUIDRequestItem.setAmount(amount);
lists.add(vip180TransferToUIDRequestItem);
vip180TransferToUIDRequest.setList(lists);
logger.debug("transfer Token from {} to {} request: {}", from, to, JSONObject.toJSONString(vip180TransferToUIDRequest));
VIP180TransferResponse vip180TransferResponse = toolChainClient.execute(vip180TransferToUIDRequest);
while (true) {
logger.debug("1.1response: {}", vip180TransferResponse);
Thread.sleep(20000);
if (vip180TransferResponse.getData() != null) {
if (vip180TransferResponse.getData().getOrderStatus().equals(OrderStatusEnum.SUCCESS.getStatus())) {
logger.debug("transfer token success");
break;
} else if (vip180TransferResponse.getData().getOrderStatus().equals(OrderStatusEnum.FAIL.getStatus())) {
logger.debug("transfer token fail");
break;
}
}
vip180TransferResponse = toolChainClient.execute(vip180TransferToUIDRequest);
}
Response Example:
{
"data":
{
"requestNo": "Thu Aug 06 14:39:34 CST 2020",
"orderStatus": "SUCCESS",
"list": [
{
"amount": "0x1",
"clauseIndex": 0,
"txID": "0xb153f5465256ac0597db73462c40276433e15777333a53ca2f2609d8a2e73ed5",
"txStatus": "SUCCESS"
}]
},
"code": 1,
"message": "success"
}
Transfer token to address
SDK Example:
String requestNo = new Date().toString();
VIP180TransferToAddressRequest vip180TransferToAddressRequest = new VIP180TransferToAddressRequest();
vip180TransferToAddressRequest.setTokenContractAddress(contractAddress180);
vip180TransferToAddressRequest.setRequestNo(requestNo);
vip180TransferToAddressRequest.setFromUID(from);
List < VIP180TransferToAddressRequestItem > lists = new ArrayList < > ();
VIP180TransferToAddressRequestItem vip180TransferToAddressRequestItem = new VIP180TransferToAddressRequestItem();
vip180TransferToAddressRequestItem.setToAddress(to);
vip180TransferToAddressRequestItem.setAmount(amount);
lists.add(vip180TransferToAddressRequestItem);
vip180TransferToAddressRequest.setList(lists);
logger.debug("transfer Token from {} to {} request: {}", from, to, JSONObject.toJSONString(vip180TransferToAddressRequest));
VIP180TransferResponse vip180TransferResponse = toolChainClient.execute(vip180TransferToAddressRequest);
while (true) {
logger.debug("response: {}", vip180TransferResponse);
Thread.sleep(20000);
if (vip180TransferResponse.getData() != null) {
if (vip180TransferResponse.getData().getOrderStatus().equals(OrderStatusEnum.SUCCESS.getStatus())) {
logger.debug("transfer token success");
break;
} else if (vip180TransferResponse.getData().getOrderStatus().equals(OrderStatusEnum.FAIL.getStatus())) {
logger.debug("transfer token fail");
break;
}
}
vip180TransferResponse = toolChainClient.execute(vip180TransferToAddressRequest);
}
Response Example:
{
"code": 1,
"data":
{
"list": [
{
"amount": "0x1",
"clauseIndex": 0,
"txID": "0x2c2004acc0a53ba3d674e3432a134a8823cca989e0d554f74f538f4fadee632b",
"txStatus": "SUCCESS"
}],
"orderStatus": "SUCCESS",
"requestNo": "Thu Aug 06 15:29:11 CST 2020"
},
"message": "success"
}
Authorize third-party account transfer
It is used to approve a third party's right to transfer tokens. There are two interfaces as follows:
-
Authorize token transfer by account in batches
-
Authorize token transfer by address in batches
Authorize token transfer by account in batches
SDK Example:
VIP180ApproveUIDRequest vip180ApproveUIDRequest = new VIP180ApproveUIDRequest();
vip180ApproveUIDRequest.setFromUID(ownerUID);
vip180ApproveUIDRequest.setTokenContractAddress(contractAddress180);
List < VIP180ApproveUIDRequestItem > lists = new ArrayList < > ();
VIP180ApproveUIDRequestItem vip180ApproveUIDRequestItem = new VIP180ApproveUIDRequestItem();
vip180ApproveUIDRequestItem.setDelegateUID(delegate_uid_add);
vip180ApproveUIDRequestItem.setAmount(amount);
lists.add(vip180ApproveUIDRequestItem);
vip180ApproveUIDRequest.setList(lists);
logger.debug("request: : {}", vip180ApproveUIDRequest);
VIP180ApproveResponse vip180ApproveResponse = toolChainClient.execute(vip180ApproveUIDRequest);
while (true) {
logger.debug("1.1response: {}", vip180ApproveResponse);
if (vip180ApproveResponse.getData() != null) {
if (vip180ApproveResponse.getData().getOrderStatus().equals(OrderStatusEnum.SUCCESS.getStatus())) {
logger.debug("approve token success");
break;
} else if (vip180ApproveResponse.getData().getOrderStatus().equals(OrderStatusEnum.FAIL.getStatus())) {
logger.debug("approve token fail");
break;
}
}
Thread.sleep(10000);
vip180ApproveResponse = toolChainClient.execute(vip180ApproveUIDRequest);
}
Response Example:
{
"code": 1,
"data":
{
"list": [
{
"amount": "0x10",
"clauseIndex": 0,
"txID": "0x97a656eea47acc6014523a9b85a6d6192c4079b605d91239f3e3487484f20e09",
"txStatus": "SUCCESS"
}],
"orderStatus": "SUCCESS",
"requestNo": "1596699074266"
},
"message": "success"
}
Authorize token transfer by address in batches
SDK Example:
VIP180ApproveAddressRequest vip180ApproveAddressRequest = new VIP180ApproveAddressRequest();
vip180ApproveAddressRequest.setFromUID(ownerUID);
vip180ApproveAddressRequest.setTokenContractAddress(contractAddress180);
List < VIP180ApproveAddressRequestItem > lists = new ArrayList < > ();
VIP180ApproveAddressRequestItem vip180ApproveAddressRequestItem = new VIP180ApproveAddressRequestItem();
vip180ApproveAddressRequestItem.setDelegateAddress(delegate_uid_add);
vip180ApproveAddressRequestItem.setAmount(amount);
lists.add(vip180ApproveAddressRequestItem);
vip180ApproveAddressRequest.setList(lists);
logger.debug("request: : {}", vip180ApproveAddressRequest);
VIP180ApproveResponse vip180ApproveResponse = toolChainClient.execute(vip180ApproveAddressRequest);
while (true) {
logger.debug("1.1response: {}", vip180ApproveResponse);
if (vip180ApproveResponse.getData() != null) {
if (vip180ApproveResponse.getData().getOrderStatus().equals(OrderStatusEnum.SUCCESS.getStatus())) {
logger.debug("approve token success");
break;
} else if (vip180ApproveResponse.getData().getOrderStatus().equals(OrderStatusEnum.FAIL.getStatus())) {
logger.debug("approve token fail");
break;
}
}
Thread.sleep(10000);
vip180ApproveResponse = toolChainClient.execute(vip180ApproveAddressRequest);
}
Response Example:
{
"code": 1,
"data":
{
"list": [
{
"amount": "0x2",
"clauseIndex": 0,
"txID": "0x0f86797f647a4832ee523e5affb006b2a504b17932b2a8ecaef1d7ed9245c45a",
"txStatus": "SUCCESS"
}],
"orderStatus": "SUCCESS",
"requestNo": "1596699415915"
},
"message": "success"
}
Query authorized transferable quota
There are the following 4 interfaces:
-
Query authorized transferable quota of account A to account B
-
Query authorized transferable quota of account A to address B
-
Query authorized transferable quota of address A to account B
- Query authorized transferable quota of address A to address B
Query authorized transferable quota of account A to account B
SDK Example:
VIP180AllowanceResponse vip180AllowanceResponse;
VIP180AllowanceOwnerUIDSpenderUIDRequest vip180AllowanceOwnerUIDSpenderUIDRequest = new VIP180AllowanceOwnerUIDSpenderUIDRequest();
vip180AllowanceOwnerUIDSpenderUIDRequest.setTokenContractAddress(contractAddress180);
vip180AllowanceOwnerUIDSpenderUIDRequest.setTokenOwnerUID(owner_uid_add);
vip180AllowanceOwnerUIDSpenderUIDRequest.setSpenderUID(spender_uid_add);
vip180AllowanceResponse = toolChainClient.execute(vip180AllowanceOwnerUIDSpenderUIDRequest);
logger.debug("{}", vip180AllowanceResponse);
Response Example:
{
"code": 1,
"data":
{
"allowed": "0x10"
},
"message": "success"
}
Query authorized transferable quota of account A to address B
SDK Example:
VIP180AllowanceResponse vip180AllowanceResponse;
VIP180AllowanceOwnerUIDSpenderAddressRequest vip180AllowanceOwnerUIDSpenderAddressRequest = new VIP180AllowanceOwnerUIDSpenderAddressRequest();
vip180AllowanceOwnerUIDSpenderAddressRequest.setTokenContractAddress(contractAddress180);
vip180AllowanceOwnerUIDSpenderAddressRequest.setTokenOwnerUID(owner_uid_add);
vip180AllowanceOwnerUIDSpenderAddressRequest.setSpenderAddress(spender_uid_add);
vip180AllowanceResponse = toolChainClient.execute(vip180AllowanceOwnerUIDSpenderAddressRequest);
logger.debug("{}", vip180AllowanceResponse);
Response Example:
{
"code": 1,
"data":
{
"allowed": "0x10"
},
"message": "success"
}
Query authorized transferable quota of address A to account B
SDK Example:
VIP180AllowanceResponse vip180AllowanceResponse;
VIP180AllowanceOwnerAddressSpenderUIDRequest vip180AllowanceOwnerAddressSpenderUIDRequest = new VIP180AllowanceOwnerAddressSpenderUIDRequest();
vip180AllowanceOwnerAddressSpenderUIDRequest.setTokenContractAddress(contractAddress180);
vip180AllowanceOwnerAddressSpenderUIDRequest.setTokenOwnerAddress(owner_uid_add);
vip180AllowanceOwnerAddressSpenderUIDRequest.setSpenderUID(spender_uid_add);
vip180AllowanceResponse = toolChainClient.execute(vip180AllowanceOwnerAddressSpenderUIDRequest);
Response Example:
{
"code": 1,
"data":
{
"allowed": "0x10"
},
"message": "success"
}
Query authorized transferable quota of address A to address B
SDK Example:
VIP180AllowanceOwnerAddressSpenderAddressRequest vip180AllowanceOwnerAddressSpenderAddressRequest = new VIP180AllowanceOwnerAddressSpenderAddressRequest();
vip180AllowanceOwnerAddressSpenderAddressRequest.setTokenContractAddress(contractAddress180);
vip180AllowanceOwnerAddressSpenderAddressRequest.setTokenOwnerAddress(owner_uid_add);
vip180AllowanceOwnerAddressSpenderAddressRequest.setSpenderAddress(spender_uid_add);
vip180AllowanceResponse = toolChainClient.execute(vip180AllowanceOwnerAddressSpenderAddressRequest);
logger.debug("{}", vip180AllowanceResponse);
Response Example:
{
"code": 1,
"data":
{
"allowed": "0x10"
},
"message": "success"
}
Authorize account to initiate transfer
To approve a third-party account, please be authorized to call transferFrom to transfer tokens from the current owner to another account/address.
There are 4 interfaces in total:
-
Authorized transfer: from account to account
-
Authorized transfer: from account to address
- Authorized transfer: from address to account
- Authorized transfer: from address to address
Authorized transfer: from account to account
SDK Example:
VIP180TransferFromUID2UIDRequest vip180TransferFromUID2UIDRequest = new VIP180TransferFromUID2UIDRequest();
vip180TransferFromUID2UIDRequest.setTokenContractAddress(contractAddress180);
vip180TransferFromUID2UIDRequest.setDelegateUID(delegate_uid);
List < VIP180TransferFromUID2UIDRequestItem > lists = new ArrayList < > ();
VIP180TransferFromUID2UIDRequestItem vip180TransferFromUID2UIDRequestItem = new VIP180TransferFromUID2UIDRequestItem();
vip180TransferFromUID2UIDRequestItem.setFromUID(from_uid_add);
vip180TransferFromUID2UIDRequestItem.setToUID(to_uid_add);
vip180TransferFromUID2UIDRequestItem.setAmount(amount);
lists.add(vip180TransferFromUID2UIDRequestItem);
vip180TransferFromUID2UIDRequest.setList(lists);
logger.debug("request: : {}", vip180TransferFromUID2UIDRequest);
VIP180TransferResponse vip180TransferResponse = toolChainClient.execute(vip180TransferFromUID2UIDRequest);
while (true) {
logger.debug("1.1response: {}", vip180TransferResponse);
Thread.sleep(20000);
if (vip180TransferResponse.getData() != null) {
if (vip180TransferResponse.getData().getOrderStatus().equals(OrderStatusEnum.SUCCESS.getStatus())) {
logger.debug("approve token success");
break;
} else if (vip180TransferResponse.getData().getOrderStatus().equals(OrderStatusEnum.FAIL.getStatus())) {
logger.debug("approve token fail");
break;
}
}
vip180TransferResponse = toolChainClient.execute(vip180TransferFromUID2UIDRequest);
}
Response Example:
{
"data":
{
"requestNo": "1596784380561",
"orderStatus": "SUCCESS",
"list": [
{
"amount": "0x1",
"clauseIndex": 0,
"txID": "0x6963c9a6adc4cd43fc5f323cf68f73c75886d7397fa17324b964d80428eefb30",
"txStatus": "SUCCESS"
}]
},
"code": 1,
"message": "success"
}
Authorized transfer: from account to address
SDK Example:
VIP180TransferFromUID2AddressRequest vip180TransferFromUID2AddressRequest = new VIP180TransferFromUID2AddressRequest();
vip180TransferFromUID2AddressRequest.setTokenContractAddress(contractAddress180);
vip180TransferFromUID2AddressRequest.setDelegateUID(delegate_uid);
List < VIP180TransferFromUID2AddressRequestItem > lists = new ArrayList < > ();
VIP180TransferFromUID2AddressRequestItem vip180TransferFromUID2AddressRequestItem = new VIP180TransferFromUID2AddressRequestItem();
vip180TransferFromUID2AddressRequestItem.setFromUID(from_uid_add);
vip180TransferFromUID2AddressRequestItem.setToAddress(to_uid_add);
vip180TransferFromUID2AddressRequestItem.setAmount(amount);
lists.add(vip180TransferFromUID2AddressRequestItem);
vip180TransferFromUID2AddressRequest.setList(lists);
logger.debug("request: : {}", vip180TransferFromUID2AddressRequest);
VIP180TransferResponse vip180TransferResponse = toolChainClient.execute(vip180TransferFromUID2AddressRequest);
while (true) {
logger.debug("1.1response: {}", vip180TransferResponse);
Thread.sleep(20000);
if (vip180TransferResponse.getData() != null) {
if (vip180TransferResponse.getData().getOrderStatus().equals(OrderStatusEnum.SUCCESS.getStatus())) {
logger.debug("approve token success");
break;
} else if (vip180TransferResponse.getData().getOrderStatus().equals(OrderStatusEnum.FAIL.getStatus())) {
logger.debug("approve token fail");
break;
}
}
vip180TransferResponse = toolChainClient.execute(vip180TransferFromUID2AddressRequest);
}
Response Example:
{
"data":
{
"requestNo": "1596784483895",
"orderStatus": "SUCCESS",
"list": [
{
"amount": "0x1",
"clauseIndex": 0,
"txID": "0x89ed7be6fd8234180247606a78616c5a9070559cf7a483e04c0db4a3c8133f6d",
"txStatus": "SUCCESS"
}]
},
"code": 1,
"message": "success"
}
Authorized transfer: from address to account
SDK Example:
VIP180TransferFromAddress2UIDRequest vip180TransferFromAddress2UIDRequest = new VIP180TransferFromAddress2UIDRequest();
vip180TransferFromAddress2UIDRequest.setTokenContractAddress(contractAddress180);
vip180TransferFromAddress2UIDRequest.setDelegateUID(delegate_uid);
List < VIP180TransferFromAddress2UIDRequestItem > lists = new ArrayList < > ();
VIP180TransferFromAddress2UIDRequestItem vip180TransferFromAddress2UIDRequestItem = new VIP180TransferFromAddress2UIDRequestItem();
vip180TransferFromAddress2UIDRequestItem.setFromAddress(from_uid_add);
vip180TransferFromAddress2UIDRequestItem.setToUID(to_uid_add);
vip180TransferFromAddress2UIDRequestItem.setAmount(amount);
lists.add(vip180TransferFromAddress2UIDRequestItem);
vip180TransferFromAddress2UIDRequest.setList(lists);
logger.debug("request: : {}", vip180TransferFromAddress2UIDRequest);
VIP180TransferResponse vip180TransferResponse = toolChainClient.execute(vip180TransferFromAddress2UIDRequest);
while (true) {
logger.debug("1.1response: {}", vip180TransferResponse);
Thread.sleep(20000);
if (vip180TransferResponse.getData() != null) {
if (vip180TransferResponse.getData().getOrderStatus().equals(OrderStatusEnum.SUCCESS.getStatus())) {
logger.debug("approve token success");
break;
} else if (vip180TransferResponse.getData().getOrderStatus().equals(OrderStatusEnum.FAIL.getStatus())) {
logger.debug("approve token fail");
break;
}
}
vip180TransferResponse = toolChainClient.execute(vip180TransferFromAddress2UIDRequest);
}
Response Example:
{
"data":
{
"requestNo": "1596784700180",
"orderStatus": "SUCCESS",
"list": [
{
"amount": "0x1",
"clauseIndex": 0,
"txID": "0xebe6454017ba32ecccddfcfbd7d70733ec9032c32ae0094c8d0fe6fe2f3a11ad",
"txStatus": "SUCCESS"
}]
},
"code": 1,
"message": "success"
}
Authorized transfer: from address to address
SDK Example:
VIP180TransferFromAddress2AddressRequest vip180TransferFromAddress2AddressRequest = new VIP180TransferFromAddress2AddressRequest();
vip180TransferFromAddress2AddressRequest.setTokenContractAddress(contractAddress180);
vip180TransferFromAddress2AddressRequest.setDelegateUID(delegate_uid);
List < VIP180TransferFromAddress2AddressRequestItem > lists = new ArrayList < > ();
VIP180TransferFromAddress2AddressRequestItem vip180TransferFromAddress2AddressRequestItem = new VIP180TransferFromAddress2AddressRequestItem();
vip180TransferFromAddress2AddressRequestItem.setFromAddress(from_uid_add);
vip180TransferFromAddress2AddressRequestItem.setToAddress(to_uid_add);
vip180TransferFromAddress2AddressRequestItem.setAmount(amount);
lists.add(vip180TransferFromAddress2AddressRequestItem);
vip180TransferFromAddress2AddressRequest.setList(lists);
logger.debug("request: : {}", vip180TransferFromAddress2AddressRequest);
VIP180TransferResponse vip180TransferResponse = toolChainClient.execute(vip180TransferFromAddress2AddressRequest);
while (true) {
logger.debug("1.1response: {}", vip180TransferResponse);
Thread.sleep(20000);
if (vip180TransferResponse.getData() != null) {
if (vip180TransferResponse.getData().getOrderStatus().equals(OrderStatusEnum.SUCCESS.getStatus())) {
logger.debug("approve token success");
break;
} else if (vip180TransferResponse.getData().getOrderStatus().equals(OrderStatusEnum.FAIL.getStatus())) {
logger.debug("approve token fail");
break;
}
}
vip180TransferResponse = toolChainClient.execute(vip180TransferFromAddress2AddressRequest);
}
Response Example:
{
"data":
{
"requestNo": "1596784802727",
"orderStatus": "SUCCESS",
"list": [
{
"amount": "0x1",
"clauseIndex": 0,
"txID": "0xd4585af959d1a5e43eca48eb85b8ff135702bdb5d5fe63ead33ad92cba2579bc",
"txStatus": "SUCCESS"
}]
},
"code": 1,
"message": "success"
}
Toggle/Query mintable status
The mintable status refers to whether the smart contract can mint tokens. The client can use the UID of the administrator account to toggle the mintable status.
Toggle mintable status
SDK Example:
VIP180SetMintableRequest vip180SetMintableRequest = new VIP180SetMintableRequest();
vip180SetMintableRequest.setOwnerUID(ownerUID);
vip180SetMintableRequest.setTokenContractAddress(contractAddress180);
vip180SetMintableRequest.setMintable(mintable);
logger.debug("request: : {}", vip180SetMintableRequest);
VIP180ManageResponse vip180ManageResponse = toolChainClient.execute(vip180SetMintableRequest);
while (true) {
logger.debug("1.1response: {}", vip180ManageResponse);
Thread.sleep(20000);
if (vip180ManageResponse.getData() != null) {
if (vip180ManageResponse.getData().getOrderStatus().equals(OrderStatusEnum.SUCCESS.getStatus())) {
logger.debug("setmintable token success");
break;
} else if (vip180ManageResponse.getData().getOrderStatus().equals(OrderStatusEnum.FAIL.getStatus())) {
logger.debug("setmintable token fail");
break;
}
}
vip180ManageResponse = toolChainClient.execute(vip180SetMintableRequest);
}
Response Example:
{
"code": 1,
"data":
{
"list": [
{
"amount": "0x10",
"clauseIndex": 0,
"txID": "0x97a656eea47acc6014523a9b85a6d6192c4079b605d91239f3e3487484f20e09",
"txStatus": "SUCCESS"
}],
"orderStatus": "SUCCESS",
"requestNo": "1596699074266"
},
"message": "success"
}
Query the mintable status of token
SDK Example:
VIP180QueryMintableRequest vip180QueryMintableRequest = new VIP180QueryMintableRequest();
logger.debug("request: : {}", vip180QueryMintableRequest);
VIP180QueryMintableResponse vip180QueryMintableResponse = toolChainClient.execute(vip180QueryMintableRequest);
logger.debug("1.1response: {}", vip180QueryMintableResponse);
Response Example:
{
"code": 1,
"data":
{
"clauseIndex": 0,
"orderStatus": "SUCCESS",
"requestNo": "1596793564784",
"txID": "0x7ce6978e620d08a01afd095ef28d7bfba8bcc44623f30ef444a48625fb8faf67"
},
"message": "success"
}
Query the token balance
There are 2 interfaces in total:
-
Query the token balance of the specified account
-
Query the token balance of the specified address
Query the token balance of the specified account
SDK Example:
VIP180BalanceOfResponse vip180BalanceOfResponse;
VIP180BalanceOfUIDRequest vip180BalanceOfUIDRequest = new VIP180BalanceOfUIDRequest();
vip180BalanceOfUIDRequest.setTokenContractAddress(contractAddress180);
vip180BalanceOfUIDRequest.setUid(address);
vip180BalanceOfResponse = toolChainClient.execute(vip180BalanceOfUIDRequest);
BigInteger value = new BigInteger(vip180BalanceOfResponse.getData().getBalance().toLowerCase().replace("0x", ""), 16);
logger.debug("address: {}, amount: {}", address, value);
Response Example:
{
"data":
{
"balance": "0x1"
},
"code": 1,
"message": "success"
}
Query the token balance of the specified address
SDK Example:
VIP180BalanceOfResponse vip180BalanceOfResponse;
VIP180BalanceOfAddressRequest vip180BalanceOfAddressRequest = new VIP180BalanceOfAddressRequest();
vip180BalanceOfAddressRequest.setTokenContractAddress(contractAddress180);
vip180BalanceOfAddressRequest.setAddress(address);
vip180BalanceOfResponse = toolChainClient.execute(vip180BalanceOfAddressRequest);
BigInteger value = new BigInteger(vip180BalanceOfResponse.getData().getBalance().toLowerCase().replace("0x", ""), 16);
logger.debug("address: {}, amount: {}", address, value);
Response Example:
{
"data":
{
"balance": "0x1"
},
"code": 1,
"message": "success"
}
Query total supply of token
SDK Example:
VIP180QueryTotalSupplyRequest vip180QueryTotalSupplyRequest = new VIP180QueryTotalSupplyRequest();
vip180QueryTotalSupplyRequest.setTokenContractAddress(contractAddress180);
VIP180QueryTotalSupplyResponse vip180QueryTotalSupplyResponse = toolChainClient.execute(vip180QueryTotalSupplyRequest);
logger.info("VIP180QueryTotalSupplyResponse: {}", vip180QueryTotalSupplyResponse);
Response Example:
{
"data":
{
"totalSupply": "0x52B7D2DCC80CD2E4000006"
},
"code": 1,
"message": "success"
}
Comments
0 comments
Please sign in to leave a comment.