API operation description

更新时间:
复制 MD 格式

Create an on-chain account

Issuers and users need an on-chain account to issue or receive warrants. An on-chain account serves as an on-chain identity. You can use this API operation to create an on-chain account. Before creating the account, you must perform identity verification for the user. After the account is created, you must associate the user with the on-chain account.

API operation

antchain.caasplatform.extend.rights.create

Request parameters

Name

Required

Type

Constraints

Example

Description

service_id

Yes

STRING

-

cme2021034016405521c119

The ID of the contract instance.

account_name

Yes

STRING

-

testAccount

The account name.

Response parameters

Name

Type

Example

Description

req_msg_id

STRING

b20167e21a8d4cc2b5f1022d24f43815

The unique ID of the request. Use this ID to track and troubleshoot issues.

result_code

STRING

OK

The result code. OK indicates that the call was successful.

result_msg

STRING

OK

The message returned for the request. If the request fails, an error message is returned.

address

STRING

01f661a065ebc437fa99ec1f867bd4d2965109f4fcacc2ae136fd0d35738099e52b1448bac137c7792753585352f3f4c5fe6c7484c1e71ecfbd9b0886ef83e13

The on-chain account address.

API example

// This file is auto-generated, don't edit it. Thanks.
package com.antgroup.antchain.openapi.sample;
 
import com.aliyun.tea.*;
import com.antgroup.antchain.openapi.caasplatform.*;
import com.antgroup.antchain.openapi.caasplatform.models.*;
 
public class Client {
 
    /**
     * Initialize the account client with an AccessKey ID and an AccessKey secret.
     * @param accessKeyId
     * @param accessKeySecret
     * @return Client
     * @throws Exception
     */
    public static com.antgroup.antchain.openapi.caasplatform.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        Config config = new Config();
        // Your AccessKey ID
        config.accessKeyId = accessKeyId;
        // Your AccessKey secret
        config.accessKeySecret = accessKeySecret;
        return new com.antgroup.antchain.openapi.caasplatform.Client(config);
    }
 
    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        // Do not save the AccessKey ID and AccessKey secret of the contract service in your project code. This practice prevents AccessKey leaks and protects the security of your contract service.
        // This example shows how to read the AccessKey of the contract service from environment variables for API authentication. Before you run the code example, configure the CONTRACT_SERVICE_ACCESS_KEY_ID and CONTRACT_SERVICE_ACCESS_SECRET environment variables.
        com.antgroup.antchain.openapi.caasplatform.Client client = Client.createClient(System.getenv("CONTRACT_SERVICE_ACCESS_KEY_ID"),
        System.getenv("CONTRACT_SERVICE_ACCESS_SECRET"));
        CreateExtendRightsRequest createExtendRightsRequest = new CreateExtendRightsRequest()
                .setServiceId("cme2021034016405521c119")
                .setAccountName("testAccount");
        client.createExtendRights(createExtendRightsRequest);
    }
}

Response example

{
  "address": "01f661a065ebc437fa99ec1f867bd4d2965109f4fcacc2ae136fd0d35738099e52b1448bac137c7792753585352f3f4c5fe6c7484c1e71ecfbd9b0886ef83e13",
  "resultCode": "OK",
  "reqMsgId": "7571290506d849e58d6fe9877eab7c99",
  "resultMsg": "OK"
}

Result codes

Result code

Description

Solutions

OK

Success code

Create a resource file

Minting a warrant requires a resource file. The resource file is a JSON string that describes the resource information. The following is an example:

{
  "name": "Test Warrant",
  "description": "This is a description of the test warrant",
  "attributes": [
    "{\"author\":\"testUser\",\"tag\":\"This is supplementary extension data\"}"
  ],
  "fileId": "https://test.al.com/lxsrpdpj3cdcea44_4.23.jpeg"
}

This string includes the name, description, and image information (fileId) of the resource file, along with its attributes. The attributes include the author and extension information, which are marked with the `tag` label.

The image information in the resource file is a URL for an image resource. This can be a publicly accessible URL that you provide. You can also upload the image using an OpenAPI. The contract service then hosts the image and assigns a publicly accessible URL to it.

If you provide an internal file ID instead of a directly accessible URL, you must transform it into an accessible URL when you query the resource file later.

API operation

antchain.caasplatform.extend.rights.upload

Request parameters

Name

Required

Type

Constraints

Example

Description

name

Yes

STRING

-

Test Warrant

The resource name.

description

No

STRING

-

This is a description of the test warrant

The resource description.

file_id

Yes

STRING

-

N/A

The resource file ID. If you use the contract service to host the file, you do not need to set this parameter. You can upload the file using the SDK. If you manage the file yourself, you can provide a publicly accessible URL (recommended) or a file ID. If you provide a file ID, you must transform the ID into an accessible URL in the final output.

data

No

STRING

-

This is supplementary extension data

The extension field.

author

Yes

STRING

-

testUser

The author or issuer. This information is used in the resource description file and can be displayed on the page.

Response parameters

Name

Type

Example

Description

req_msg_id

STRING

b20167e21a8d4cc2b5f1022d24f43815

The unique ID of the request. Use this ID to track and troubleshoot issues.

result_code

STRING

OK

The result code. OK indicates that the call was successful.

result_msg

STRING

OK

The message returned for the request. If the request fails, an error message is returned.

rights_id

LONG

N/A

The data asset ID. This ID is used for subsequent operations such as asset minting.

API example

// This file is auto-generated, don't edit it. Thanks.
package com.antgroup.antchain.openapi.sample;
 
import com.aliyun.tea.*;
import com.antgroup.antchain.openapi.caasplatform.*;
import com.antgroup.antchain.openapi.caasplatform.models.*;
 
public class Client {
 
    /**
     * Initialize the account client with an AccessKey ID and an AccessKey secret.
     * @param accessKeyId
     * @param accessKeySecret
     * @return Client
     * @throws Exception
     */
    public static com.antgroup.antchain.openapi.caasplatform.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        Config config = new Config();
        // Your AccessKey ID
        config.accessKeyId = accessKeyId;
        // Your AccessKey secret
        config.accessKeySecret = accessKeySecret;
        return new com.antgroup.antchain.openapi.caasplatform.Client(config);
    }
 
    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        // Do not save the AccessKey ID and AccessKey secret of the contract service in your project code. This practice prevents AccessKey leaks and protects the security of your contract service.
        // This example shows how to read the AccessKey of the contract service from environment variables for API authentication. Before you run the code example, configure the CONTRACT_SERVICE_ACCESS_KEY_ID and CONTRACT_SERVICE_ACCESS_SECRET environment variables.
        com.antgroup.antchain.openapi.caasplatform.Client client = Client.createClient(System.getenv("CONTRACT_SERVICE_ACCESS_KEY_ID"),
        System.getenv("CONTRACT_SERVICE_ACCESS_SECRET")); 
        UploadExtendRightsRequest uploadExtendRightsRequest = new UploadExtendRightsRequest()
                .setData("This is supplementary extension data")
                .setAuthor("testUser")
                .setName("Test Warrant")
                .setDescription("This is a description of the test warrant");
        // The following code shows how to create a resource file and upload it using the file hosting service.
        File file = new File("path/to/your/asset/file");
        uploadExtendRightsRequest.setFileObjectName(file.getName());
        uploadExtendRightsRequest.setFileObject(new FileInputStream(file));
        client.uploadExtendRights(uploadExtendRightsRequest);
    }
}

If you do not use the file hosting service and manage the resource file yourself, modify the preceding example as follows.

        // The following code shows how to create a resource file and upload it using the file hosting service.
        File file = new File("path/to/your/asset/file");
        uploadExtendRightsRequest.setFileObjectName(file.getName());
        uploadExtendRightsRequest.setFileObject(new FileInputStream(file));
  • You can provide a directly accessible URL.

            // Provide a directly accessible URL.
            uploadExtendRightsRequest.setFileId("https://test.al.com/lxsrpdpj3cdcea44_4.23.jpeg");
  • You can also manage the file yourself.

            // Provide a unique ID for the file that you manage. In the data returned from a subsequent query for the resource file,
            // transform the FileID into an accessible URL.
            uploadExtendRightsRequest.setFileId("asfainnerasda1313asda1r");

Response example

{
  "rightsId": 171922085292216,
  "resultCode": "OK",
  "reqMsgId": "70f7a36d3b3140c0b13a69de09747b4c",
  "resultMsg": "OK"
}

Result codes

Result code

Description

Solutions

OK

Successful result code

Warrant minting

Warrant minting is the process of issuing warrants. A digital warrant contract can issue a batch of warrants. Warrants in this batch share the same tokenId.

API operation

antchain.caasplatform.general.rights.register

Request parameters

Name

Required

Type

Constraints

Example

Description

service_id

Yes

STRING

-

cme2021034016405521c119

The ID of the contract instance.

account

Yes

STRING

-

testAccount

The accountName specified when the on-chain account was created.

id

Yes

LONG

-

171922085292216

The resource ID returned by calling the hosted resource API operation: rights_id.

amount

Yes

LONG

-

100

The number of data assets to mint.

data

No

STRING

-

N/A

The extension parameter.

Response parameters

Name

Type

Example

Description

req_msg_id

STRING

b20167e21a8d4cc2b5f1022d24f43815

The unique ID of the request. Use this ID to track and troubleshoot issues.

result_code

STRING

OK

The result code. OK indicates that the call was successful.

result_msg

STRING

OK

The message returned for the request. If the request fails, an error message is returned.

tx_hash

STRING

c73c751472a9f9fbceef29665101377ba7e170b649b83db33b4634d4484ac626

The transaction hash of the contract call.

block_number

LONG

10000

The block height of the contract call transaction.

code

LONG

0

The error code of the contract call. 0 indicates success.

API example

// This file is auto-generated, don't edit it. Thanks.
package com.antgroup.antchain.openapi.sample;
 
import com.aliyun.tea.*;
import com.antgroup.antchain.openapi.caasplatform.*;
import com.antgroup.antchain.openapi.caasplatform.models.*;
 
public class Client {
 
    /**
     * Initialize the account client with an AccessKey ID and an AccessKey secret.
     * @param accessKeyId
     * @param accessKeySecret
     * @return Client
     * @throws Exception
     */
    public static com.antgroup.antchain.openapi.caasplatform.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        Config config = new Config();
        // Your AccessKey ID
        config.accessKeyId = accessKeyId;
        // Your AccessKey secret
        config.accessKeySecret = accessKeySecret;
        return new com.antgroup.antchain.openapi.caasplatform.Client(config);
    }
 
    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        // Do not save the AccessKey ID and AccessKey secret of the contract service in your project code. This practice prevents AccessKey leaks and protects the security of your contract service.
        // This example shows how to read the AccessKey of the contract service from environment variables for API authentication. Before you run the code example, configure the CONTRACT_SERVICE_ACCESS_KEY_ID and CONTRACT_SERVICE_ACCESS_SECRET environment variables.
        com.antgroup.antchain.openapi.caasplatform.Client client = Client.createClient(System.getenv("CONTRACT_SERVICE_ACCESS_KEY_ID"),
        System.getenv("CONTRACT_SERVICE_ACCESS_SECRET"));
        RegisterGeneralRightsRequest registerGeneralRightsRequest = new RegisterGeneralRightsRequest()
                .setServiceId("cme2021034016405521c119")
                .setAccount("testAccount")
                .setAmount(100L)
                .setId(171922085292216L);
        client.registerGeneralRights(registerGeneralRightsRequest);
    }
}

Response example

{
  "code": 0,
  "blockNumber": 20929865,
  "resultCode": "OK",
  "txHash": "4309817fd1fb76e9b47b07619dc48cd14d0c8118553bb39f24ec629e935eb465",
  "reqMsgId": "4715d546c5804bb9b16cf451357ed833",
  "resultMsg": "OK"
}

Result codes

Result code

Description

Solutions

OK

Success Code

Warrant transfer

When a user purchases a warrant or an issuer gives a warrant as a gift, the warrant is transferred from the issuer to the recipient.

API operation

antchain.caasplatform.general.rights.pay

Request parameters

Name

Required

Type

Constraints

Example

Description

service_id

Yes

STRING

-

cme2021034016405521c119

The ID of the contract instance.

from

Yes

STRING

-

testAccount

The name of the on-chain account that holds the asset.

to

Yes

STRING

-

toUserAccount

The name of the on-chain account that receives the asset.

id

Yes

LONG

-

171922085292216

The data asset ID.

amount

Yes

LONG

-

10

The number of data assets to transfer.

data

No

STRING

-

N/A

The extension data.

Response parameters

Name

Type

Example

Description

req_msg_id

STRING

b20167e21a8d4cc2b5f1022d24f43815

The unique ID of the request. Use this ID to track and troubleshoot issues.

result_code

STRING

OK

The result code. OK indicates that the call was successful.

result_msg

STRING

OK

The message returned for the request. If the request fails, an error message is returned.

tx_hash

STRING

c73c751472a9f9fbceef29665101377ba7e170b649b83db33b4634d4484ac626

The transaction hash of the contract call.

block_number

LONG

10000

The block height of the contract call transaction.

code

LONG

0

The error code of the contract call. 0 indicates success.

API example

// This file is auto-generated, don't edit it. Thanks.
package com.antgroup.antchain.openapi.sample;
 
import com.aliyun.tea.*;
import com.antgroup.antchain.openapi.caasplatform.*;
import com.antgroup.antchain.openapi.caasplatform.models.*;
 
public class Client {
 
    /**
     * Initialize the account client with an AccessKey ID and an AccessKey secret.
     * @param accessKeyId
     * @param accessKeySecret
     * @return Client
     * @throws Exception
     */
    public static com.antgroup.antchain.openapi.caasplatform.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        Config config = new Config();
        // Your AccessKey ID
        config.accessKeyId = accessKeyId;
        // Your AccessKey secret
        config.accessKeySecret = accessKeySecret;
        return new com.antgroup.antchain.openapi.caasplatform.Client(config);
    }
 
    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        // Do not save the AccessKey ID and AccessKey secret of the contract service in your project code. This practice prevents AccessKey leaks and protects the security of your contract service.
        // This example shows how to read the AccessKey of the contract service from environment variables for API authentication. Before you run the code example, configure the CONTRACT_SERVICE_ACCESS_KEY_ID and CONTRACT_SERVICE_ACCESS_SECRET environment variables.
        com.antgroup.antchain.openapi.caasplatform.Client client = Client.createClient(System.getenv("CONTRACT_SERVICE_ACCESS_KEY_ID"),
        System.getenv("CONTRACT_SERVICE_ACCESS_SECRET"));
        PayGeneralRightsRequest payGeneralRightsRequest = new PayGeneralRightsRequest()
                .setServiceId("cme2021034016405521c119")
                .setFrom("testAccount")
                .setTo("toUserAccount")
                .setId(171922085292216L)
                .setAmount(1L);
        client.payGeneralRights(payGeneralRightsRequest);
    }
}

Response example

{
  "code": 0,
  "blockNumber": 20930209,
  "resultCode": "OK",
  "txHash": "d3e5f5bc657ba4fec8301abf8fc9aa4f4d4789af02489d9bae0e367be52cd71a",
  "reqMsgId": "55ee78971a794e3bb82c56fed015808a",
  "resultMsg": "OK"
}

Result codes

Result code

Description

Solutions

OK

Success code

Query a resource file

After you create a resource file, you can call this API operation to query the content of the resource file.

API operation

antchain.caasplatform.general.rights.get

Request parameters

Name

Required

Type

Constraints

Example

Description

service_id

Yes

STRING

-

cme2021034016405521c119

The ID of the contract instance.

token_id

Yes

LONG

-

171922085292216

The data asset ID.

Response parameters

Name

Type

Example

Description

req_msg_id

STRING

b20167e21a8d4cc2b5f1022d24f43815

The unique ID of the request. Use this ID to track and troubleshoot issues.

result_code

STRING

OK

The result code. OK indicates that the call was successful.

result_msg

STRING

OK

The message returned for the request. If the request fails, an error message is returned.

tx_hash

STRING

c73c751472a9f9fbceef29665101377ba7e170b649b83db33b4634d4484ac626

The transaction hash of the contract call.

block_number

LONG

10000

The block height of the contract call transaction.

code

LONG

0

The error code of the contract call. 0 indicates success.

result

STRING

https://caas-backend-prod.antdigital.com/caas/contract/extend/getAssetUri/171922085292216

The description file of the resource that corresponds to the asset. This is a JSON string.

The `result` parameter in the response contains the resource file. For more information about the file format and details, see Create a resource file.

API example

// This file is auto-generated, don't edit it. Thanks.
package com.antgroup.antchain.openapi.sample;
 
import com.aliyun.tea.*;
import com.antgroup.antchain.openapi.caasplatform.*;
import com.antgroup.antchain.openapi.caasplatform.models.*;
 
public class Client {
 
    /**
     * Initialize the account client with an AccessKey ID and an AccessKey secret.
     * @param accessKeyId
     * @param accessKeySecret
     * @return Client
     * @throws Exception
     */
    public static com.antgroup.antchain.openapi.caasplatform.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        Config config = new Config();
        // Your AccessKey ID
        config.accessKeyId = accessKeyId;
        // Your AccessKey secret
        config.accessKeySecret = accessKeySecret;
        return new com.antgroup.antchain.openapi.caasplatform.Client(config);
    }
 
    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        // Do not save the AccessKey ID and AccessKey secret of the contract service in your project code. This practice prevents AccessKey leaks and protects the security of your contract service.
        // This example shows how to read the AccessKey of the contract service from environment variables for API authentication. Before you run the code example, configure the CONTRACT_SERVICE_ACCESS_KEY_ID and CONTRACT_SERVICE_ACCESS_SECRET environment variables.
        com.antgroup.antchain.openapi.caasplatform.Client client = Client.createClient(System.getenv("CONTRACT_SERVICE_ACCESS_KEY_ID"),
        System.getenv("CONTRACT_SERVICE_ACCESS_SECRET"));
        GetGeneralRightsRequest getGeneralRightsRequest = new GetGeneralRightsRequest()
                .setTokenId(171922085292216L)
                .setServiceId("cme2021034016405521c119");
        client.getGeneralRights(getGeneralRightsRequest);
    }
}

Response example

{
  "result": "https://caas-backend-prod.antdigital.com/caas/contract/extend/getAssetUri/171922085292216",
  "code": 0,
  "blockNumber": 20929866,
  "resultCode": "OK",
  "txHash": "d8aa1ed871a6f1c3574f253b5cc67337e0f91cb300b2f5b3fde343858eb87832",
  "reqMsgId": "25af2ab547e547f487e91b4747b45d14",
  "resultMsg": "OK"
}

Result codes

Result code

Description

Solutions

OK

Success Code

Query the asset balance of an account

Queries the quantity of a specific asset that an account owns.

API operation

antchain.caasplatform.general.rightsbalance.get

Request parameters

Name

Required

Type

Constraints

Example

Description

service_id

Yes

STRING

-

cme2021034016405521c119

The ID of the contract instance.

account

Yes

STRING

-

sltest24081303

The account address.

id

Yes

LONG

-

171922085292216

The data asset ID.

Response parameters

Name

Type

Example value

Description

req_msg_id

STRING

b20167e21a8d4cc2b5f1022d24f43815

A unique ID for the request, used for link tracing and troubleshooting.

result_code

STRING

OK

The result code. OK indicates that the call was successful.

result_msg

STRING

OK

The message returned for the request. If the request fails, this parameter provides a description of the failure.

tx_hash

STRING

c73c751472a9f9fbceef29665101377ba7e170b649b83db33b4634d4484ac626

The transaction hash of the contract call.

block_number

LONG

10000

The block height of the contract call transaction.

code

LONG

0

The error code of the contract call. A value of 0 indicates success.

result

STRING

The description file for the Asset's resource file. This is a JSON string.

The `result` parameter in the response contains a resource file. For more information about the file format and description, see Create a resource file.

API example

// This file is auto-generated, don't edit it. Thanks.
package com.antgroup.antchain.openapi.sample;
 
import com.aliyun.tea.*;
import com.antgroup.antchain.openapi.caasplatform.*;
import com.antgroup.antchain.openapi.caasplatform.models.*;
 
public class Client {
 
    /**
     * Initialize the account client with an AccessKey ID and an AccessKey secret.
     * @param accessKeyId
     * @param accessKeySecret
     * @return Client
     * @throws Exception
     */
    public static com.antgroup.antchain.openapi.caasplatform.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        Config config = new Config();
        // Your AccessKey ID
        config.accessKeyId = accessKeyId;
        // Your AccessKey secret
        config.accessKeySecret = accessKeySecret;
        return new com.antgroup.antchain.openapi.caasplatform.Client(config);
    }
 
    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.antgroup.antchain.openapi.caasplatform.Client client = Client.createClient("accessKeyId", "accessKeySecret");
        GetGeneralRightsbalanceRequest request = new GetGeneralRightsbalanceRequest();
        request.setServiceId("cme2021034016405521c119");
        request.setAccount("sltest24081303");
        request.setId(171922085292216L);
        GetGeneralRightsbalanceResponse response = client.getGeneralRightsbalance(request);
    }
}

Response example

{
  "blockNumber": 120384752,
  "code": 0,
  "reqMsgId": "043b28078b354266b4d04ae372bf65de",
  "result": "21",
  "resultCode": "OK",
  "resultMsg": "OK",
  "txHash": "6466ed67793ba561e672a93863ce2f0dc548cf2acc12dfe8e2602f36604ee3a5"
}

Result codes

Result code

Description

Solutions

OK

Success result code