Samsung Blockchain Platform SDK manages the address on Blockchain as an account. It contains the information required for signing and the Blockchain address.
Get Instance
getAccountManager API is callable from the SBlockchain instance. If the SBlockchain instance is not initialized, an IllegalStateException is thrown.
getAccounts API returns the accounts stored in shared preference. It supports three parameters for filtering: walletId, CoinType, and NetworkType. Each parameter is optional and can be null to get all stored accounts.
generateNewAccount API generates a new account that has the HD Path according to the BIP-32 standard and creates an address based on it. Before creation, the AccountManager retrieves previously used accounts derived from the root seed and place it in the next index. If an account with no history on Blockchain has already been created, an AccountException is thrown or RootSeedChangedException is thrown if the root seed has changed.
Ethereum
CoinNetworkInfo coinNetworkInfo = new CoinNetworkInfo(
CoinType.ETH,
EthereumNetworkType.MAINNET,
RPC_ENDPOINT);
ListenableFutureTask.Callback<Account> generatingNewAccountCallback =
new ListenableFutureTask.Callback<Account>() {
@Override
public void onSuccess(Account account) {
Log.i(TAG, "Generated account address: " + account.getAddress());
}
@Override
public void onFailure(ExecutionException e) {
Throwable cause = e.getCause();
if (cause instanceof AccountException) {
// handling account error
} else if (cause instanceof RootSeedChangedException) {
// handling root seed changed exception
} else if (cause instanceof RemoteClientException) {
// handling network error
}
}
@Override
public void onCancelled(InterruptedException e) {
}
};
accountManager
.generateNewAccount(
connectedHardwareWallet,
coinNetworkInfo
).setCallback(generatingNewAccountCallback);
Tron
CoinNetworkInfo coinNetworkInfo = new CoinNetworkInfo(
CoinType.TRX,
TronNetworkType.MAINNET,
RPC_ENDPOINT);
ListenableFutureTask.Callback<Account> generatingNewAccountCallback =
new ListenableFutureTask.Callback<Account>() {
@Override
public void onSuccess(Account account) {
Log.i(TAG, "Generated account address: " + account.getAddress());
}
@Override
public void onFailure(ExecutionException e) {
Throwable cause = e.getCause();
if (cause instanceof AccountException) {
// handling account error
} else if (cause instanceof RootSeedChangedException) {
// handling root seed changed exception
} else if (cause instanceof RemoteClientException) {
// handling network error
}
}
@Override
public void onCancelled(InterruptedException e) {
}
};
accountManager
.generateNewAccount(
connectedHardwareWallet,
coinNetworkInfo
).setCallback(generatingNewAccountCallback);
The parameters to take note of are as follows:
hardwareWallet : is currently connected to the HardwareWallet to derive the address from the root seed.
coinNetworkInfo : Blockchain information of the account to be created. It requires a CoinType, NetworkType, and RPC node address.
Restore Accounts
Deprecated :
This API was deprecated in 1.1.00.
Changed restoreTarget as a single CoinNetworkInfo because only one coin type can be processed at a time on the ledger device.
Use restoreAccounts(HardwareWallet, Boolean, CoinNetworkInfo) instead.
The restoreAccounts API retrieves previously used accounts from the root seed of the target HardwareWallet and stores them in a shared preference. It derives the address using the HD Path according to the BIP-32 standard and checks if the address has a Blockchain history. The HD Path rules are provided by the AccountManager that conform to the BIP-44 standard. Alternatively, you can specify HD Path rule as a parameter.
Ethereum
CoinNetworkInfo coinNetworkInfo = new CoinNetworkInfo(
CoinType.ETH,
EthereumNetworkType.MAINNET,
RPC_ENDPOINT);
ListenableFutureTask.Callback<Boolean> restoreAccountsCallback =
new ListenableFutureTask.Callback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
}
@Override
public void onFailure(ExecutionException exception) {
Throwable cause = e.getCause();
if (cause instanceof AccountException) {
// handling account error
} else if (cause instanceof RootSeedChangedException) {
// handling root seed changed exception
} else if (cause instanceof RemoteClientException) {
// handling network error
}
}
@Override
public void onCancelled(InterruptedException exception) {
}
});
accountManager
.restoreAccounts(
connectedWallet,
false,
coinNetworkInfo
).setCallback(restoreAccountsCallback);
Tron
CoinNetworkInfo coinNetworkInfo = new CoinNetworkInfo(
CoinType.TRX,
TronNetworkType.MAINNET,
RPC_ENDPOINT);
ListenableFutureTask.Callback<Boolean> restoreAccountsCallback =
new ListenableFutureTask.Callback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
}
@Override
public void onFailure(ExecutionException exception) {
Throwable cause = e.getCause();
if (cause instanceof AccountException) {
// handling account error
} else if (cause instanceof RootSeedChangedException) {
// handling root seed changed exception
} else if (cause instanceof RemoteClientException) {
// handling network error
}
}
@Override
public void onCancelled(InterruptedException exception) {
}
});
mAccountManager
.restoreAccounts(
connectedWallet,
false,
coinNetworkInfo
).setCallback(restoreAccountsCallback);
The parameters to take note of are as follows:
hardwareWallet : is currently connected to the HardwareWallet to derive address from root seed.
reset : whether to clear accounts. If true, remove all accounts in the shared preferences and write restored accounts.
restoreTargets : Blockchain information of the account to be created. It requires a CoinType, NetworkType, and RPC node address.
How to handle the returned value : The return value is a list of failed cases in restoreTarget, and an empty list is returned if all of the requested targets are successful.
Manage Your Cookies
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
.samsungdeveloperconference.com
Analytical/Performance Cookies
These cookies collect information about how you use our website. for example which
pages you visit most often. All information these cookies collect is used to improve
how the website works.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Functionality Cookies
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and
tailor the website to provide enhanced features and content for you.
Company
Domain
LinkedIn
.ads.linkedin.com, .linkedin.com
Advertising Cookies
These cookies gather information about your browser habits. They remember that
you've visited our website and share this information with other organizations such
as advertisers.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Preferences Submitted
You have successfully updated your cookie preferences.