Create an account
createAccount
This API is called synchronously to create an account.
public CreateAccountResponse createAccount(CreateAccountRequest request)
| Parameter |
Required |
Type |
Description |
| request |
true |
CreateAccountRequest |
The request for creating an account. |
| Response field |
Field type |
Description |
| result |
CreateAccountResponse |
The response for creating an account. |
// Create an account and transfer an amount.// CreateAccountRequest request = new CreateAccountRequest(accountId, account, amount); // Create an account based on accountId.CreateAccountRequest request = new CreateAccountRequest(accountId, account);// Refer to the error message description document to check the returned data.CreateAccountResponse response = sdk.getAccountService().createAccount(request);
asyncCreateAccount
This API is called asynchronously to create an account.
public int asyncCreateAccount(CreateAccountRequest request, IAsyncCallback callback)
| Parameter |
Required |
Type |
Description |
| request |
true |
CreateAccountRequest |
The request for creating an account. |
| callback |
true |
IAsyncCallback |
The callback function. |
| 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. |
// Create an account based on accountId.CreateAccountRequest request = new CreateAccountRequest(accountId, account);int result = sdk.getAccountService().asyncCreateAccount( request, new IAsyncCallback() { @Override public void onResponse(int errorCode, Response response) { // Refer to the error message description document to check the returned data. System.out.println("async create account, errorCode:" + errorCode + ", response: " + response.getErrorCode()); } });
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.
public TransferBalanceResponse transferBalance(TransferBalanceRequest request)
| Parameter |
Required |
Type |
Description |
| request |
true |
TransferBalanceRequest |
The transaction transfer request. |
| Response field |
Field type |
Description |
| response |
TransferBalanceResponse |
The transaction transfer response. |
TransferBalanceRequest request = TransferBalanceRequest(id, receiverId, amount);//transfer balance// Refer to the error message description document to check the returned data.TransferBalanceResponse response = sdk.getAccountService().transferBalance(request);
asyncTransferBalance
This API is called asynchronously for transaction transfer.
public int asyncTransferBalance(TransferBalanceRequest request, IAsyncCallback callback)
| Parameter |
Required |
Type |
Description |
| request |
true |
TransferBalanceRequest |
The transaction transfer request. |
| callback |
true |
IAsyncCallback |
The callback function. |
| Response field |
Field type |
Description |
| result |
int |
The return value. |
TransferBalanceRequest request = TransferBalanceRequest(id, receiverId, amount);// async transfer balanceint result = sdk.getAccountService().asyncTransferBalance( request, new IAsyncCallback() { @Override public void onResponse(int errorCode, Response response) { // Refer to the error message description document to check the returned data. System.out.println("async transfer balance, errorCode:" + errorCode + ", response: " + response.getErrorCode()); } });
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.
public SetRecoverKeyResponse setRecoverKey(SetRecoverKeyRequest request)
| Parameter |
Required |
Type |
Description |
| request |
true |
SetRecoverKeyRequest |
The request for setting a recovery public key. |
| Response field |
Field type |
Description |
| response |
SetRecoverKeyResponse |
The response for setting a recovery public key. |
SetRecoverKeyRequest request = new SetRecoverKeyRequest(acctId, recoverPubKey);// Refer to the error message description document to check the returned data.SetRecoverKeyResponse response = sdk.getAccountService().setRecoverKey(request);
asyncSetRecoverKey
This API is called asynchronously to set a recovery public key.
public int asyncSetRecoverKey(SetRecoverKeyRequest request, IAsyncCallback callback)
| Parameter |
Required |
Type |
Description |
| request |
true |
SetRecoverKeyRequest |
The request for setting a recovery public key. |
| callback |
true |
IAsyncCallback |
The callback function. |
| Response field |
Field type |
Description |
| result |
int |
The return value. |
SetRecoverKeyRequest request = new SetRecoverKeyRequest(acctId, recoverPubKey)int result = sdk.getAccountService().asyncSetRecoverKey( request, new IAsyncCallback() { @Override public void onResponse(int errorCode, Response response) { // Refer to the error message description document to check the returned data. System.out.println("async set recover key, errorCode:" + errorCode + ", response: " + response.getErrorCode()); } });
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.
public PreResetPubKeyResponse preResetPubKey(PreResetPubKeyRequest request)
| Parameter |
Required |
Type |
Description |
| request |
true |
PreResetPubKeyRequest |
The request for presetting a public key. |
| Response field |
Field type |
Description |
| response |
PreResetPubKeyResponse |
The response for presetting a public key. |
PreResetPubKeyRequest request = new PreResetPubKeyRequest(acctId);// Refer to the error message description document to check the returned data. PreResetPubKeyResponse response = sdk.getAccountService().preResetPubKey(request);
asyncPreResetPubKey
This API is called asynchronously to preset a public key.
public int asyncPreResetPubKey(PreResetPubKeyRequest request, IAsyncCallback callback)
| Parameter |
Required |
Type |
Description |
| request |
true |
PreResetPubKeyRequest |
The request for presetting a public key. |
| callback |
true |
IAsyncCallback |
The callback function. |
| Response field |
Field type |
Description |
| result |
int |
The return value. |
PreResetPubKeyRequest request = new PreResetPubKeyRequest(acctId);int result = sdk.getAccountService().asyncPreResetPubKey(request, new IAsyncCallback() { @Override public void onResponse(int errorCode, Response response) { // Refer to the error message description document to check the returned data. System.out.println("async reset pubkey, errorCode:" + errorCode + ", response: " + response.getErrorCode()); } });
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.
public ResetPubKeyResponse resetPublicKey(ResetPubKeyRequest request)
| Parameter |
Required |
Type |
Description |
| request |
true |
ResetPubKeyRequest |
The request for resetting a public key. |
| Response field |
Field type |
Description |
| response |
ResetPubKeyResponse |
The response for resetting a public key. |
ResetPubKeyRequest request = new ResetPubKeyRequest(acctId, authMap);// Refer to the error message description document to check the returned data.ResetPubKeyResponse response = sdk.getAccountService().resetPubKey(request);
asyncResetPubKey
This API is called asynchronously to reset a public key.
public int asyncResetPubKey(ResetPubKeyRequest request,IAsyncCallback callback)
| Parameter |
Required |
Type |
Description |
| request |
true |
ResetPubKeyRequest |
The request for resetting a public key. |
| callback |
true |
IAsyncCallback |
The callback function. |
| Response field |
Field type |
Description |
| result |
int |
The return value. |
ResetPubKeyRequest request = new ResetPubKeyRequest(acctId, authMap); // reset public keyint response = sdk.getAccountService().asyncResetPubKey( request, new IAsyncCallback() { @Override public void onResponse(int errorCode, Response response) { // Refer to the error message description document to check the returned data. System.out.println("async reset pubkey, errorCode:" + errorCode + ", response: " + response.getErrorCode()); } });
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.
public UpdateAuthMapResponse updateAuthMap(UpdateAuthMapRequest request)
| Parameter |
Required |
Type |
Description |
| request |
true |
UpdateAuthMapRequest |
The weight update request. |
| Response field |
Field type |
Description |
| response |
UpdateAuthMapResponse |
The weight update response. |
UpdateAuthMapRequest request = new UpdateAuthMapRequest(acctId, authMap);// Refer to the error message description document to check the returned data. UpdateAuthMapResponse response = sdk.getAccountService().updateAuthMap(request);
asyncUpdateAuthMap
This API is called asynchronously to update a weight.
public int asyncUpdateAuthMap(UpdateAuthMapRequest request,IAsyncCallback callback)
| Parameter |
Required |
Type |
Description |
| request |
true |
UpdateAuthMapRequest |
The weight update request. |
| callback |
true |
IAsyncCallback |
The callback function. |
| Response field |
Field type |
Description |
| result |
int |
The return value. |
UpdateAuthMapRequest request = new UpdateAuthMapRequest(acctId, authMap);int result = sdk.getAccountService().asyncUpdateAuthMap( request, new IAsyncCallback() { @Override public void onResponse(int errorCode, Response response) { // Refer to the error message description document to check the returned data. System.out.println("async update auth map, errorCode:" + errorCode + ", response: " + response.getErrorCode()); } });
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.
public FreezeAccountResponse freezeAccount(FreezeAccountRequest request)
| Parameter |
Required |
Type |
Description |
| request |
true |
FreezeAccountRequest |
The request for freezing an account. |
| Response field |
Field type |
Description |
| response |
FreezeAccountResponse |
The response for freezing an account. |
FreezeAccountRequest request = new FreezeAccountRequest(from, to);// Refer to the error message description document to check the returned data. FreezeAccountResponse result = sdk.getAccountService().freezeAccount(request)
asyncFreezeAccount
This API is called asynchronously to freeze an account.
public int asyncFreezeAccount(FreezeAccountRequest request,IAsyncCallback callback)
| Parameter |
Required |
Type |
Description |
| request |
true |
FreezeAccountRequest |
The request for freezing an account. |
| callback |
true |
IAsyncCallback |
The callback function. |
| Response field |
Field type |
Description |
| result |
int |
The return value. |
FreezeAccountRequest request = new FreezeAccountRequest(from, to);// async freeze accountint result = sdk.getAccountService().asyncFreezeAccount( request , new IAsyncCallback() { @Override public void onResponse(int errorCode, Response response) { // Refer to the error message description document to check the returned data. System.out.println("async freeze account, errorCode:" + errorCode + ", response: " + response.getErrorCode()); } });
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.
public UnFreezeAccountResponse unFreezeAccount(UnFreezeAccountRequest request)
| Parameter |
Required |
Type |
Description |
| request |
true |
UnFreezeAccountRequest |
The request for unfreezing an account. |
| Response field |
Field type |
Description |
| response |
UnFreezeAccountResponse |
The response for unfreezing an account. |
UnfreezeAccountRequest request = new UnFreezeAccountRequest(id, frozenId);// unfreeze account// Refer to the error message description document to check the returned data. UnFreezeAccountResponse response = sdk.getAccountService().unFreezeAccount(request);
asyncUnFreezeAccount
This API is called asynchronously to unfreeze an account.
public int asyncUnFreezeAccount(UnFreezeAccountRequest request,IAsyncCallback callback)
| Parameter |
Required |
Type |
Description |
| request |
true |
UnFreezeAccountRequest |
The request for unfreezing an account. |
| callback |
true |
IAsyncCallback |
The callback function. |
| Response field |
Field type |
Description |
| result |
int |
The return value. |
UnFreezeAccountRequest request = new UnfreezeAccountRequest(id, frozenId);// async unfreeze accountint result = sdk.getAccountService().asyncUnFreezeAccount( request, new IAsyncCallback() { @Override public void onResponse(int errorCode, Response response) { // Refer to the error message description document to check the returned data. System.out.println("async unFreeze account, errorCode:" + errorCode + ", response: " + response.getErrorCode()); } });
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.
public UpdateEncryptionKeyResponse updateEncryptionKey(UpdateEncryptionKeyRequest request)
| Parameter |
Required |
Type |
Description |
| request |
true |
UpdateEncryptionKeyRequest |
The request for updating an encryption key. |
| Response field |
Field type |
Description |
| response |
UpdateEncryptionKeyResponse |
The response for updating an encryption key. |
UpdateEncryptionKeyRequest request = new UpdateEncryptionKeyRequest(acctId, encryptionKey);// Refer to the error message description document to check the returned data. UpdateEncryptionKeyResponse response = sdk.getAccountService().updateEncryptionKey(request);
asyncUpdateEncryptionKey
This API is called asynchronously to update an encryption key.
public int asyncUpdateEncryptionKey(UpdateEncryptionKeyRequest request,IAsyncCallback callback)
| Parameter |
Required |
Type |
Description |
| request |
true |
UpdateEncryptionKeyRequest |
The request for updating an encryption key. |
| callback |
true |
IAsyncCallback |
The callback function. |
| Response field |
Field type |
Description |
| result |
int |
The return value. |
UpdateEncryptionKeyRequest request = new UpdateEncryptionKeyRequest(acctId, encryptionKey);int result = sdk.getAccountService().asyncUpdateEncryptionKey( request, new IAsyncCallback() { @Override public void onResponse(int errorCode, Response response) { // Refer to the error message description document to check the returned data. System.out.println("async update encryption key, errorCode:" + errorCode + ", response: " + response.getErrorCode()); } });
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. |