All Products
Search
Document Center

Blockchain as a Service:Account Interface

Last Updated:Mar 31, 2026

The account service (sdk.getAccountService()) exposes methods to manage on-chain accounts in the Mychain network. Each method follows the same pattern: build a request object, call the method, and handle the response.

  • Synchronous methods block until the transaction is confirmed and return MychainBase<ReplyTransactionReceipt>.

  • Asynchronous methods return immediately and deliver the result to an ICallback callback, returning MychainBase<Response>.

This reference covers the following operations:

All examples use the following common parameters block:

MychainParams params = new MychainParams.Builder()
    .gas(BigInteger.valueOf(40000))
    .privateKeyList(adminPrivateKeys)
    .build();

Create accounts

createAccount

Creates an account synchronously.

Signature

public MychainBase<ReplyTransactionReceipt> createAccount(CreateAccountRequest request)

Request parameters

ParameterRequiredTypeDescription
requestYesCreateAccountRequestThe account creation request.

Response

FieldTypeDescription
resultMychainBase<ReplyTransactionReceipt>Contains a response field with the transaction receipt.

Example

MychainBase<ReplyTransactionReceipt> result = sdk.getAccountService().createAccount(
    CreateAccountRequest.build(
        adminAccount.getIdentity(), testAccount1, params
    )
);

asyncCreateAccount

Creates an account asynchronously. The result is delivered to the ICallback callback once the transaction is confirmed.

Signature

public MychainBase<Response> asyncCreateAccount(CreateAccountRequest request, ICallback callback)

Request parameters

ParameterRequiredTypeDescription
requestYesCreateAccountRequestThe account creation request.
callbackYesICallbackThe callback that receives the transaction hash and response.

Response

FieldTypeDescription
resultMychainBase<Response>Contains a response field.

Example

MychainBase<Response> result = sdk.getAccountService().asyncCreateAccount(
    CreateAccountRequest.build(adminAccount.getIdentity(), testAccount3, params),
    new ICallback() {
        @Override
        public void onResponse(String txHash, Response response) {
            System.out.println("async create account, txHash:" + txHash + ", result: " + response.getErrorCode());
        }
    });

CreateAccountRequest

FieldTypeDescription
accountAccountThe account to create.
fromAccountIdIdentityThe identity of the creator. The creator must have sufficient permissions.
mychainParamsMychainParamsCommon parameters, including gas limit and signing keys.

Transfers

transferBalance

Transfers balance between accounts synchronously.

Signature

public MychainBase<ReplyTransactionReceipt> transferBalance(TransferBalanceRequest request)

Request parameters

ParameterRequiredTypeDescription
requestYesTransferBalanceRequestThe transfer request.

Response

FieldTypeDescription
resultMychainBase<ReplyTransactionReceipt>Contains a response field with the transaction receipt.

Example

MychainParams params = new MychainParams.Builder()
    .gas(BigInteger.valueOf(40000))
    .privateKeyList(adminPrivateKeys)
    .build();

MychainBase<ReplyTransactionReceipt> result = sdk.getAccountService().transferBalance(
    TransferBalanceRequest.build(
        testAccount1.getIdentity(),
        testAccount2.getIdentity(),
        new BigInteger(transferAmount + ""),
        params
    )
);

asyncTransferBalance

Transfers balance between accounts asynchronously.

Signature

public MychainBase<Response> asyncTransferBalance(TransferBalanceRequest request, ICallback callback)

Request parameters

ParameterRequiredTypeDescription
requestYesTransferBalanceRequestThe transfer request.
callbackYesICallbackThe callback that receives the transaction hash and response.

Response

FieldTypeDescription
resultMychainBase<Response>Contains a response field.

Example

MychainParams params = new MychainParams.Builder()
    .gas(BigInteger.valueOf(40000))
    .privateKeyList(adminPrivateKeys)
    .build();

MychainBase<Response> result = sdk.getAccountService().asyncTransferBalance(
    TransferBalanceRequest.build(
        testAccount2.getIdentity(),
        testAccount1.getIdentity(),
        new BigInteger(transferAmount + ""),
        params),
    (txHash, response) -> {
        System.out.println("async transfer balance, txHash:" + txHash
            + ", result: " + response.getErrorCode());
    }
);

TransferBalanceRequest

FieldTypeDescription
fromAcctIdIdentityThe identity of the sending account.
toAcctIdIdentityThe identity of the receiving account.
amountBigIntegerThe amount to transfer.
mychainParamsMychainParamsCommon parameters, including gas limit and signing keys.

Set recovery keys

setRecoverKey

Sets the recovery public key for an account synchronously. The recovery key enables the two-step public key reset flow (preResetPubKey followed by resetPubKey).

Signature

public MychainBase<ReplyTransactionReceipt> setRecoverKey(SetRecoverKeyRequest request)

Request parameters

ParameterRequiredTypeDescription
requestYesSetRecoverKeyRequestThe request to set a recovery public key.

Response

FieldTypeDescription
resultMychainBase<ReplyTransactionReceipt>Contains a response field with the transaction receipt.

Example

MychainParams params = new MychainParams.Builder()
    .gas(BigInteger.valueOf(40000))
    .privateKeyList(adminPrivateKeys)
    .build();

MychainBase<ReplyTransactionReceipt> result = sdk.getAccountService().setRecoverKey(
    SetRecoverKeyRequest.build(testAccount1.getIdentity(), newRecoverKey, params));

asyncSetRecoverKey

Sets the recovery public key for an account asynchronously.

Signature

public MychainBase<Response> asyncSetRecoverKey(SetRecoverKeyRequest request, ICallback callback)

Request parameters

ParameterRequiredTypeDescription
requestYesSetRecoverKeyRequestThe request to set a recovery public key.
callbackYesICallbackThe callback that receives the transaction hash and response.

Response

FieldTypeDescription
resultMychainBase<Response>Contains a response field.

Example

MychainParams params = new MychainParams.Builder()
    .gas(BigInteger.valueOf(40000))
    .privateKeyList(adminPrivateKeys)
    .build();

MychainBase<Response> result = sdk.getAccountService().asyncSetRecoverKey(
    SetRecoverKeyRequest.build(testAccount1.getIdentity(), newRecoverKey, params),
    new ICallback() {
        @Override
        public void onResponse(String txHash, Response response) {
            System.out.println("async set recover key, txHash:" + txHash
                + ", result: " + response.getErrorCode());
        }
    });

SetRecoverKeyRequest

FieldTypeDescription
acctIdIdentityThe identity of the account to update.
recoverPubKeyStringThe new recovery public key.
mychainParamsMychainParamsCommon parameters, including gas limit and signing keys.

Pre-reset public keys

Resetting an account's public key requires two steps: call preResetPubKey first to initiate the rotation, then call resetPubKey to complete it.

preResetPubKey

Initiates the public key reset process synchronously.

Signature

public MychainBase<ReplyTransactionReceipt> preResetPubKey(PreResetPubKeyRequest request)

Request parameters

ParameterRequiredTypeDescription
requestYesPreResetPubKeyRequestThe request to initiate the public key reset.

Response

FieldTypeDescription
resultMychainBase<ReplyTransactionReceipt>Contains a response field with the transaction receipt.

Example

MychainParams params = new MychainParams.Builder()
    .gas(BigInteger.valueOf(40000))
    .privateKeyList(adminPrivateKeys)
    .build();

MychainBase<ReplyTransactionReceipt> result = sdk.getAccountService().preResetPubKey(
    PreResetPubKeyRequest.build(acctId, params));

asyncPreResetPubKey

Initiates the public key reset process asynchronously.

Signature

public MychainBase<Response> asyncPreResetPubKey(PreResetPubKeyRequest request, ICallback callback)

Request parameters

ParameterRequiredTypeDescription
requestYesPreResetPubKeyRequestThe request to initiate the public key reset.
callbackYesICallbackThe callback that receives the transaction hash and response.

Response

FieldTypeDescription
resultMychainBase<Response>Contains a response field.

Example

MychainParams params = new MychainParams.Builder()
    .gas(BigInteger.valueOf(40000))
    .privateKeyList(adminPrivateKeys)
    .build();

MychainBase<Response> response = sdk.getAccountService().asyncPreResetPubKey(
    PreResetPubKeyRequest.build(accId, params),
    new ICallback() {
        @Override
        public void onResponse(String txHash, Response response) {
            // Handle pre-reset confirmation
        }
    });

PreResetPubKeyRequest

FieldTypeDescription
acctIdIdentityThe identity of the account whose public key will be reset.
mychainParamsMychainParamsCommon parameters, including gas limit and signing keys.

Reset public keys

Call resetPubKey or asyncResetPubKey after a successful preResetPubKey call to complete the key rotation.

resetPubKey

Completes the public key reset synchronously.

Signature

public MychainBase<ReplyTransactionReceipt> resetPubKey(ResetPubKeyRequest request)

Request parameters

ParameterRequiredTypeDescription
requestYesResetPubKeyRequestThe request to complete the public key reset.

Response

FieldTypeDescription
resultMychainBase<ReplyTransactionReceipt>Contains a response field with the transaction receipt.

Example

MychainParams params = new MychainParams.Builder()
    .gas(BigInteger.valueOf(40000))
    .privateKeyList(adminPrivateKeys)
    .build();

MychainBase<Response> response = sdk.getAccountService().resetPubKey(
    ResetPubKeyRequest.build(testAccount1.getIdentity(), authMap, params));

asyncResetPubKey

Completes the public key reset asynchronously.

Signature

public MychainBase<Response> asyncResetPubKey(ResetPubKeyRequest request, ICallback callback)

Request parameters

ParameterRequiredTypeDescription
requestYesResetPubKeyRequestThe request to complete the public key reset.
callbackYesICallbackThe callback that receives the transaction hash and response.

Response

FieldTypeDescription
resultMychainBase<Response>Contains a response field.

Example

MychainParams params = new MychainParams.Builder()
    .gas(BigInteger.valueOf(40000))
    .privateKeyList(adminPrivateKeys)
    .build();

MychainBase<Response> response = sdk.getAccountService().asyncResetPubKey(
    ResetPubKeyRequest.build(testAccount1.getIdentity(), beforeAuthMap, params),
    new ICallback() {
        @Override
        public void onResponse(String txHash, Response response) {
            System.out.println("async reset pubkey, txHash:" + txHash
                + ", result: " + response.getErrorCode());
        }
    });

ResetPubKeyRequest

FieldTypeDescription
acctIdIdentityThe identity of the account whose public key is being reset.
mychainParamsMychainParamsCommon parameters, including gas limit and signing keys.

Update weights

Each account has an auth map (AuthMap) that maps public key hex strings to integer weights. The total weight of the signing keys used in a transaction must meet the account's threshold to authorize operations.

updateAuthMap

Updates the auth map (key weights) for an account synchronously.

Signature

public MychainBase<ReplyTransactionReceipt> updateAuthMap(UpdateAuthMapRequest request)

Request parameters

ParameterRequiredTypeDescription
requestYesUpdateAuthMapRequestThe request to update the auth map.

Response

FieldTypeDescription
resultMychainBase<ReplyTransactionReceipt>Contains a response field with the transaction receipt.

Example

MychainParams params = new MychainParams.Builder()
    .gas(BigInteger.valueOf(40000))
    .privateKeyList(adminPrivateKeys)
    .build();

MychainBase<ReplyTransactionReceipt> response = sdk.getAccountService().updateAuthMap(
    UpdateAuthMapRequest.build(testAccount1.getIdentity(), beforeAuthMap, params));

asyncUpdateAuthMap

Updates the auth map (key weights) for an account asynchronously.

Signature

public MychainBase<Response> asyncUpdateAuthMap(UpdateAuthMapRequest request, ICallback callback)

Request parameters

ParameterRequiredTypeDescription
requestYesUpdateAuthMapRequestThe request to update the auth map.
callbackYesICallbackThe callback that receives the transaction hash and response.

Response

FieldTypeDescription
resultMychainBase<Response>Contains a response field.

Example

The following example fetches the current auth map, increments every key's weight by 10, then submits the update.

MychainParams params = new MychainParams.Builder()
    .gas(BigInteger.valueOf(40000))
    .privateKeyList(adminPrivateKeys)
    .build();

AuthMap beforeAuthMap = sdk.getQueryService()
    .queryAccount(testAccount1.getIdentity().hexStrValue())
    .getData().getAccount().getAuthMap();

for (Map.Entry<String, Integer> entry : beforeAuthMap.getAuthMap().entrySet()) {
    beforeAuthMap.updateAuth(entry.getKey(), entry.getValue() + 10);
}

MychainBase<Response> result = sdk.getAccountService().asyncUpdateAuthMap(
    UpdateAuthMapRequest.build(testAccount1.getIdentity(), beforeAuthMap, params),
    new ICallback() {
        @Override
        public void onResponse(String txHash, Response response) {
            System.out.println("async update auth map, txHash:" + txHash
                + ", result: " + response.getErrorCode());
        }
    });

UpdateAuthMapRequest

FieldTypeDescription
acctIdIdentityThe identity of the account to update.
authMapAuthMapThe new auth map. Each entry maps a public key hex string to an integer weight. Use authMap.updateAuth(pubKeyHex, weight) to set individual entries.
mychainParamsMychainParamsCommon parameters, including gas limit and signing keys.

Freeze accounts

Important

Only an account with admin privileges can freeze another account. Pass the admin account's identity as the from parameter. If the calling identity lacks sufficient permissions, the transaction fails with a permission error.

freezeAccount

Freezes an account synchronously. A frozen account cannot initiate transactions.

Signature

public MychainBase<ReplyTransactionReceipt> freezeAccount(FreezeAccountRequest request)

Request parameters

ParameterRequiredTypeDescription
requestYesFreezeAccountRequestThe freeze request.

Response

FieldTypeDescription
resultMychainBase<ReplyTransactionReceipt>Contains a response field with the transaction receipt.

Example

MychainParams params = new MychainParams.Builder()
    .gas(BigInteger.valueOf(40000))
    .privateKeyList(adminPrivateKeys)
    .build();

MychainBase<ReplyTransactionReceipt> result = sdk.getAccountService().freezeAccount(
    FreezeAccountRequest.build(adminAccount.getIdentity(), testAccount1.getIdentity(), params));

asyncFreezeAccount

Freezes an account asynchronously.

Signature

public MychainBase<Response> asyncFreezeAccount(FreezeAccountRequest request, ICallback callback)

Request parameters

ParameterRequiredTypeDescription
requestYesFreezeAccountRequestThe freeze request.
callbackYesICallbackThe callback that receives the transaction hash and response.

Response

FieldTypeDescription
resultMychainBase<Response>Contains a response field.

Example

MychainParams params = new MychainParams.Builder()
    .gas(BigInteger.valueOf(40000))
    .privateKeyList(adminPrivateKeys)
    .build();

MychainBase<Response> result = sdk.getAccountService().asyncFreezeAccount(
    FreezeAccountRequest.build(adminAccount.getIdentity(), testAccount1.getIdentity(), params),
    new ICallback() {
        @Override
        public void onResponse(String txHash, Response response) {
            assertNotNull(txHash);
            assertTrue(response.getErrorCode().isSuccess());
        }
    });

FreezeAccountRequest

FieldTypeDescription
fromIdentityThe identity of the admin account initiating the freeze.
toIdentityThe identity of the account to freeze.
mychainParamsMychainParamsCommon parameters, including gas limit and signing keys.

Unfreeze accounts

Important

Only an account with admin privileges can unfreeze an account. Pass the admin account's identity as the from parameter.

unFreezeAccount

Unfreezes an account synchronously.

Signature

public MychainBase<ReplyTransactionReceipt> unFreezeAccount(UnfreezeAccountRequest request)

Request parameters

ParameterRequiredTypeDescription
requestYesUnfreezeAccountRequestThe unfreeze request.

Response

FieldTypeDescription
resultMychainBase<ReplyTransactionReceipt>Contains a response field with the transaction receipt.

Example

MychainParams params = new MychainParams.Builder()
    .gas(BigInteger.valueOf(40000))
    .privateKeyList(adminPrivateKeys)
    .build();

MychainBase<ReplyTransactionReceipt> result2 = sdk.getAccountService()
    .unFreezeAccount(
        UnfreezeAccountRequest.build(adminAccount.getIdentity(),
            testAccount1.getIdentity(), params));

asyncUnFreezeAccount

Unfreezes an account asynchronously.

Signature

public MychainBase<Response> asyncUnFreezeAccount(UnfreezeAccountRequest request, ICallback callback)

Request parameters

ParameterRequiredTypeDescription
requestYesUnfreezeAccountRequestThe unfreeze request.
callbackYesICallbackThe callback that receives the transaction hash and response.

Response

FieldTypeDescription
resultMychainBase<Response>Contains a response field.

Example

MychainParams params = new MychainParams.Builder()
    .gas(BigInteger.valueOf(40000))
    .privateKeyList(adminPrivateKeys)
    .build();

MychainBase<Response> result2 = sdk.getAccountService().asyncUnFreezeAccount(
    UnfreezeAccountRequest.build(adminAccount.getIdentity(), testAccount1.getIdentity(), params),
    new ICallback() {
        @Override
        public void onResponse(String txHash, Response response) {
            assertNotNull(txHash);
            assertTrue(response.getErrorCode().isSuccess());
        }
    });

UnfreezeAccountRequest

FieldTypeDescription
fromIdentityThe identity of the admin account initiating the unfreeze.
toIdentityThe identity of the account to unfreeze.
mychainParamsMychainParamsCommon parameters, including gas limit and signing keys.