All Products
Search
Document Center

Blockchain as a Service:Account interface

Last Updated:May 08, 2020

Create an account

createAccount

This API is called synchronously to create an account.

  • Function prototype
  1. public CreateAccountResponse createAccount(CreateAccountRequest request)
  • Request parameter
Parameter Required Type Description
request true CreateAccountRequest The request for creating an account.
  • Response field
Response field Field type Description
result CreateAccountResponse The response for creating an account.
  • Example
  1. // Create an account and transfer an amount.
  2. // CreateAccountRequest request = new CreateAccountRequest(accountId, account, amount);
  3. // Create an account based on accountId.
  4. CreateAccountRequest request = new CreateAccountRequest(accountId, account);
  5. // Refer to the error message description document to check the returned data.
  6. CreateAccountResponse response = sdk.getAccountService().createAccount(request);

asyncCreateAccount

This API is called asynchronously to create an account.

  • Function prototype
  1. public int asyncCreateAccount(CreateAccountRequest request, IAsyncCallback callback)
  • Request parameter
Parameter Required Type Description
request true CreateAccountRequest The request for creating an account.
callback true IAsyncCallback The callback function.
  • Response field
Response field Field type Description
result int The return value.
  • Asynchronous response field
Response field Field type Description
errorCode int Indicates whether the SDK successfully sends the message or the sending times out.
response Response The response returned by the platform, where response.getErrorCode() indicates the error code.
  • Example
  1. // Create an account based on accountId.
  2. CreateAccountRequest request = new CreateAccountRequest(accountId, account);
  3. int result = sdk.getAccountService().asyncCreateAccount(
  4. request,
  5. new IAsyncCallback() {
  6. @Override
  7. public void onResponse(int errorCode, Response response) {
  8. // Refer to the error message description document to check the returned data.
  9. System.out.println("async create account, errorCode:" + errorCode + ", response: " + response.getErrorCode());
  10. }
  11. });

CreateAccountRequest

The following table describes parameters for creating an account.

Parameter Type Description
account Account The account to be created.
accountId Identity The ID of the account to be created.

CreateAccountResponse

The following table describes response parameters for creating an account.

Parameter Type Description
transactionReceipt TransactionReceipt The transaction receipt.
blockNumber BigInteger The block number.

Transfer

transferBalance

This API is called synchronously for transaction transfer.

  • Function prototype
  1. public TransferBalanceResponse transferBalance(TransferBalanceRequest request)
  • Request parameter
Parameter Required Type Description
request true TransferBalanceRequest The transaction transfer request.
  • Response field
Response field Field type Description
response TransferBalanceResponse The transaction transfer response.
  • Example
  1. TransferBalanceRequest request = TransferBalanceRequest(id, receiverId, amount);
  2. //transfer balance
  3. // Refer to the error message description document to check the returned data.
  4. TransferBalanceResponse response = sdk.getAccountService().transferBalance(request);

asyncTransferBalance

This API is called asynchronously for transaction transfer.

  • Function prototype
  1. public int asyncTransferBalance(TransferBalanceRequest request, IAsyncCallback callback)
  • Request parameter
Parameter Required Type Description
request true TransferBalanceRequest The transaction transfer request.
callback true IAsyncCallback The callback function.
  • Response field
Response field Field type Description
result int The return value.
  • Example
  1. TransferBalanceRequest request = TransferBalanceRequest(id, receiverId, amount);
  2. // async transfer balance
  3. int result = sdk.getAccountService().asyncTransferBalance(
  4. request,
  5. new IAsyncCallback() {
  6. @Override
  7. public void onResponse(int errorCode, Response response) {
  8. // Refer to the error message description document to check the returned data.
  9. System.out.println("async transfer balance, errorCode:" + errorCode + ", response: " + response.getErrorCode());
  10. }
  11. });

TransferBalanceRequest

The following table describes parameters required for transfer.

Parameter Type Description
id Identity The transfer-out account.
receiverId Identity The transfer-in account.
amount BigInteger The transfer amount.

TransferBalanceResponse

The following table describes response parameters for transfer.

Parameter Type Description
transactionReceipt TransactionReceipt The transaction receipt.
blockNumber BigInteger The block number.

Set a recovery public key

setRecoverKey

This API is called synchronously to set a recovery public key.

  • Function prototype
  1. public SetRecoverKeyResponse setRecoverKey(SetRecoverKeyRequest request)
  • Request parameter
Parameter Required Type Description
request true SetRecoverKeyRequest The request for setting a recovery public key.
  • Response field
Response field Field type Description
response SetRecoverKeyResponse The response for setting a recovery public key.
  • Example
  1. SetRecoverKeyRequest request = new SetRecoverKeyRequest(acctId, recoverPubKey);
  2. // Refer to the error message description document to check the returned data.
  3. SetRecoverKeyResponse response = sdk.getAccountService().setRecoverKey(request);

asyncSetRecoverKey

This API is called asynchronously to set a recovery public key.

  • Function prototype
  1. public int asyncSetRecoverKey(SetRecoverKeyRequest request, IAsyncCallback callback)
  • Request parameter
Parameter Required Type Description
request true SetRecoverKeyRequest The request for setting a recovery public key.
callback true IAsyncCallback The callback function.
  • Response field
Response field Field type Description
result int The return value.
  • Example
  1. SetRecoverKeyRequest request = new SetRecoverKeyRequest(acctId, recoverPubKey)
  2. int result = sdk.getAccountService().asyncSetRecoverKey(
  3. request,
  4. new IAsyncCallback() {
  5. @Override
  6. public void onResponse(int errorCode, Response response) {
  7. // Refer to the error message description document to check the returned data.
  8. System.out.println("async set recover key, errorCode:" + errorCode + ", response: " + response.getErrorCode());
  9. }
  10. });

SetRecoverKeyRequest

The following table describes parameters for setting a recovery public key.

Parameter Type Description
acctId Identity The ID of the account to be set.
recoverPubKey String The new recovery public key.

SetRecoverKeyResponse

The following table describes response parameters for setting a recovery public key.

Parameter Type Description
transactionReceipt TransactionReceipt The transaction receipt.
blockNumber BigInteger The block number.

Preset a public key

preResetPubKey

This API is called synchronously to preset a public key.

  • Function prototype
  1. public PreResetPubKeyResponse preResetPubKey(PreResetPubKeyRequest request)
  • Request parameter
Parameter Required Type Description
request true PreResetPubKeyRequest The request for presetting a public key.
  • Response field
Response field Field type Description
response PreResetPubKeyResponse The response for presetting a public key.
  • Example
  1. PreResetPubKeyRequest request = new PreResetPubKeyRequest(acctId);
  2. // Refer to the error message description document to check the returned data.
  3. PreResetPubKeyResponse response = sdk.getAccountService().preResetPubKey(request);

asyncPreResetPubKey

This API is called asynchronously to preset a public key.

  • Function prototype
  1. public int asyncPreResetPubKey(PreResetPubKeyRequest request, IAsyncCallback callback)
  • Request parameter
Parameter Required Type Description
request true PreResetPubKeyRequest The request for presetting a public key.
callback true IAsyncCallback The callback function.
  • Response field
Response field Field type Description
result int The return value.
  • Example
  1. PreResetPubKeyRequest request = new PreResetPubKeyRequest(acctId);
  2. int result = sdk.getAccountService().asyncPreResetPubKey(request, new IAsyncCallback() {
  3. @Override
  4. public void onResponse(int errorCode, Response response) {
  5. // Refer to the error message description document to check the returned data.
  6. System.out.println("async reset pubkey, errorCode:" + errorCode + ", response: " + response.getErrorCode());
  7. }
  8. });

PreResetPubKeyRequest

The following table describes a parameter for presetting a public key.

Parameter Type Description
acctId Identity The ID of the account to be preset.

PreResetPubKeyResponse

The following table describes response parameters for presetting a public key.

Parameter Type Description
transactionReceipt TransactionReceipt The transaction receipt.
blockNumber BigInteger The block number.

Reset a public key

resetPublicKey

This API is called synchronously to reset a public key.

  • Function prototype
  1. public ResetPubKeyResponse resetPublicKey(ResetPubKeyRequest request)
  • Request parameter
Parameter Required Type Description
request true ResetPubKeyRequest The request for resetting a public key.
  • Response field
Response field Field type Description
response ResetPubKeyResponse The response for resetting a public key.
  • Example
  1. ResetPubKeyRequest request = new ResetPubKeyRequest(acctId, authMap);
  2. // Refer to the error message description document to check the returned data.
  3. ResetPubKeyResponse response = sdk.getAccountService().resetPubKey(request);

asyncResetPubKey

This API is called asynchronously to reset a public key.

  • Function prototype
  1. public int asyncResetPubKey(ResetPubKeyRequest request,IAsyncCallback callback)
  • Request parameter
Parameter Required Type Description
request true ResetPubKeyRequest The request for resetting a public key.
callback true IAsyncCallback The callback function.
  • Response field
Response field Field type Description
result int The return value.
  • Example
  1. ResetPubKeyRequest request = new ResetPubKeyRequest(acctId, authMap);
  2. // reset public key
  3. int response = sdk.getAccountService().asyncResetPubKey(
  4. request,
  5. new IAsyncCallback() {
  6. @Override
  7. public void onResponse(int errorCode, Response response) {
  8. // Refer to the error message description document to check the returned data.
  9. System.out.println("async reset pubkey, errorCode:" + errorCode + ", response: " + response.getErrorCode());
  10. }
  11. });

ResetPubKeyRequest

The following table describes parameters for resetting a public key.

Parameter Type Description
acctId Identity The ID of the account to be reset.
authMap AuthMap The public key and weight of the account or contract.

ResetPubKeyResponse

The following table describes response parameters for resetting a public key.

Parameter Type Description
transactionReceipt TransactionReceipt The transaction receipt.
blockNumber BigInteger The block number.

Update a weight

updateAuthMap

This API is called synchronously to update a weight.

  • Function prototype
  1. public UpdateAuthMapResponse updateAuthMap(UpdateAuthMapRequest request)
  • Request parameter
Parameter Required Type Description
request true UpdateAuthMapRequest The weight update request.
  • Response field
Response field Field type Description
response UpdateAuthMapResponse The weight update response.
  • Example
  1. UpdateAuthMapRequest request = new UpdateAuthMapRequest(acctId, authMap);
  2. // Refer to the error message description document to check the returned data.
  3. UpdateAuthMapResponse response = sdk.getAccountService().updateAuthMap(request);

asyncUpdateAuthMap

This API is called asynchronously to update a weight.

  • Function prototype
  1. public int asyncUpdateAuthMap(UpdateAuthMapRequest request,IAsyncCallback callback)
  • Request parameter
Parameter Required Type Description
request true UpdateAuthMapRequest The weight update request.
callback true IAsyncCallback The callback function.
  • Response field
Response field Field type Description
result int The return value.
  • Example
  1. UpdateAuthMapRequest request = new UpdateAuthMapRequest(acctId, authMap);
  2. int result = sdk.getAccountService().asyncUpdateAuthMap(
  3. request,
  4. new IAsyncCallback() {
  5. @Override
  6. public void onResponse(int errorCode, Response response) {
  7. // Refer to the error message description document to check the returned data.
  8. System.out.println("async update auth map, errorCode:" + errorCode + ", response: " + response.getErrorCode());
  9. }
  10. });

UpdateAuthMapRequest

The following table describes parameters for updating a weight.

Parameter Type Description
acctId Identity The ID of the account to be set.
authMap AuthMap The new weight authmap.

UpdateAuthMapResponse

The following table describes response parameters for updating a weight.

Parameter Type Description
transactionReceipt TransactionReceipt The transaction receipt.
blockNumber BigInteger The block number.

Freeze an account

freezeAccount

This API is called synchronously to freeze an account.

  • Function prototype
  1. public FreezeAccountResponse freezeAccount(FreezeAccountRequest request)
  • Request parameter
Parameter Required Type Description
request true FreezeAccountRequest The request for freezing an account.
  • Response field
Response field Field type Description
response FreezeAccountResponse The response for freezing an account.
  • Example
  1. FreezeAccountRequest request = new FreezeAccountRequest(from, to);
  2. // Refer to the error message description document to check the returned data.
  3. FreezeAccountResponse result = sdk.getAccountService().freezeAccount(request)

asyncFreezeAccount

This API is called asynchronously to freeze an account.

  • Function prototype
  1. public int asyncFreezeAccount(FreezeAccountRequest request,IAsyncCallback callback)
  • Request parameter
Parameter Required Type Description
request true FreezeAccountRequest The request for freezing an account.
callback true IAsyncCallback The callback function.
  • Response field
Response field Field type Description
result int The return value.
  • Example
  1. FreezeAccountRequest request = new FreezeAccountRequest(from, to);
  2. // async freeze account
  3. int result = sdk.getAccountService().asyncFreezeAccount(
  4. request
  5. , new IAsyncCallback() {
  6. @Override
  7. public void onResponse(int errorCode, Response response) {
  8. // Refer to the error message description document to check the returned data.
  9. System.out.println("async freeze account, errorCode:" + errorCode + ", response: " + response.getErrorCode());
  10. }
  11. });

FreezeAccountRequest

The following table describes parameters for freezing an account.

Parameter Type Description
from Identity The ID of the operator who freezes the account.
to Identity The ID of the account to be frozen.

FreezeAccountResponse

The following table describes response parameters for freezing an account.

Parameter Type Description
transactionReceipt TransactionReceipt The transaction receipt.
blockNumber BigInteger The block number.

Unfreeze an account

unFreezeAccount

This API is called synchronously to unfreeze an account.

  • Function prototype
  1. public UnFreezeAccountResponse unFreezeAccount(UnFreezeAccountRequest request)
  • Request parameter
Parameter Required Type Description
request true UnFreezeAccountRequest The request for unfreezing an account.
  • Response field
Response field Field type Description
response UnFreezeAccountResponse The response for unfreezing an account.
  • Example
  1. UnfreezeAccountRequest request = new UnFreezeAccountRequest(id, frozenId);
  2. // unfreeze account
  3. // Refer to the error message description document to check the returned data.
  4. UnFreezeAccountResponse response = sdk.getAccountService().unFreezeAccount(request);

asyncUnFreezeAccount

This API is called asynchronously to unfreeze an account.

  • Function prototype
  1. public int asyncUnFreezeAccount(UnFreezeAccountRequest request,IAsyncCallback callback)
  • Request parameter
Parameter Required Type Description
request true UnFreezeAccountRequest The request for unfreezing an account.
callback true IAsyncCallback The callback function.
  • Response field
Response field Field type Description
result int The return value.
  • Example
  1. UnFreezeAccountRequest request = new UnfreezeAccountRequest(id, frozenId);
  2. // async unfreeze account
  3. int result = sdk.getAccountService().asyncUnFreezeAccount(
  4. request,
  5. new IAsyncCallback() {
  6. @Override
  7. public void onResponse(int errorCode, Response response) {
  8. // Refer to the error message description document to check the returned data.
  9. System.out.println("async unFreeze account, errorCode:" + errorCode + ", response: " + response.getErrorCode());
  10. }
  11. });

UnfreezeAccountRequest

The following table describes parameters for unfreezing an account.

Parameter Type Description
from Identity The ID of the operator who unfreezes the account.
to Identity The ID of the account to be unfrozen.

UnFreezeAccountResponse

The following table describes response parameters for unfreezing an account.

Parameter Type Description
transactionReceipt TransactionReceipt The transaction receipt.
blockNumber BigInteger The block number.

Update an encryption key

updateEncryptionKey

This API is called synchronously to update an encryption key.

  • Function prototype
  1. public UpdateEncryptionKeyResponse updateEncryptionKey(UpdateEncryptionKeyRequest request)
  • Request parameter
Parameter Required Type Description
request true UpdateEncryptionKeyRequest The request for updating an encryption key.
  • Response field
Response field Field type Description
response UpdateEncryptionKeyResponse The response for updating an encryption key.
  • Example
  1. UpdateEncryptionKeyRequest request = new UpdateEncryptionKeyRequest(acctId, encryptionKey);
  2. // Refer to the error message description document to check the returned data.
  3. UpdateEncryptionKeyResponse response = sdk.getAccountService().updateEncryptionKey(request);

asyncUpdateEncryptionKey

This API is called asynchronously to update an encryption key.

  • Function prototype
  1. public int asyncUpdateEncryptionKey(UpdateEncryptionKeyRequest request,IAsyncCallback callback)
  • Request parameter
Parameter Required Type Description
request true UpdateEncryptionKeyRequest The request for updating an encryption key.
callback true IAsyncCallback The callback function.
  • Response field
Response field Field type Description
result int The return value.
  • Example
  1. UpdateEncryptionKeyRequest request = new UpdateEncryptionKeyRequest(acctId, encryptionKey);
  2. int result = sdk.getAccountService().asyncUpdateEncryptionKey(
  3. request,
  4. new IAsyncCallback() {
  5. @Override
  6. public void onResponse(int errorCode, Response response) {
  7. // Refer to the error message description document to check the returned data.
  8. System.out.println("async update encryption key, errorCode:" + errorCode + ", response: " + response.getErrorCode());
  9. }
  10. });

UpdateEncryptionKeyRequest

The following table describes parameters for updating an encryption key.

Parameter Type Description
acctId Identity The ID of the operator who updates the encryption key.
encryptionKey byte[] The encryption key.

UpdateEncryptionKeyResponse

The following table describes response parameters for updating an encryption key.

Parameter Type Description
transactionReceipt TransactionReceipt The transaction receipt.
blockNumber BigInteger The block number.