Samsung Blockchain Platform SDK supports various cold wallets. It can be managed using HardwareWalletManager, and can get an instance from SBlockchain. Currently, there are two types of HardwareWallet, Samsung Blockchain Keystore and the Ledger Nano.
Get Instance
getHardwareWalletManager is a callable instance of SBlockchain. If the SBlockchain instance is not initialized, an IllegalStateException will be thrown.
The HardwareWallet should be connected to sign, create, or restore an account. The connect API requires two mandatory parameters, HardwareWalletType and whether to clear the saved accounts. The HardwareWalletType is used to target its connection. There are two connection types: USB and Bluetooth, and is specific for the Ledger Nano X.
For USB connections, the device must be connected through OTG. A bonding state is required for Bluetooth connections. To connect a ledger device, the latest Ethereum application is installed on the ledger device and can be connected while running. If ready to connect, the connect API can be called.
ListenableFutureTask<HardwareWallet> connectionTask =
hardwareWalletManager.connect(hardwareWalletType, true);
connectionTask.setCallback(
new ListenableFutureTask.Callback<HardwareWallet>() {
@Override
public void onSuccess(HardwareWallet hardwareWallet) {
}
@Override
public void onFailure(ExecutionException e) {
Throwable cause = e.getCause();
if (cause instanceof HardwareWalletException) {
// handling hardware wallet error
} else if (cause instanceof RootSeedChangedException) {
// handling root seed changed exception
}
}
@Override
public void onCancelled(InterruptedException e) {
}
});
The parameters to take note of are as follows:
hardwareWalletType : target HardwareWallet to connect.
reset : whether to clear accounts. Samsung Blockchain Platform SDK only supports one root seed for each HardwareWallet for account management. If the root seed is changed by resetting the HardwareWallet, when the connect API is called, onFailure is called and the RootSeedChangedException is returned.
Disconnect
disconnect API is related to the target connection of the HardwareWallet. It is recommended to call it before closing your application or even before connecting to another HardwareWallet. If the disconnect API is not called, the broadcast receiver may continue to work.
hardwareWalletManager.disconnect(hardwareWallet);
Get Connected HardwareWallet
getConnectedHardwareWallet API returns an instance of the connected HardwareWallet. APIs that use the root seed requires an instance of connected HardwareWallet, so they can get the HardwareWallet connected and call it before calling them. If no HardwareWallet is connected, a null is returned.
HardwareWallet instance is returned through the HardwareWalletManager that has APIs that support its feature. getSupportedCoins API returns a list of CoinType provided by the HardwareWallet and Samsung Blockchain Platform SDK in common.
List supportedCoinTypes = hardwareWalletManager.getConnectedHardwareWallet().getSupportedCoins();
StringBuilder sb = new StringBuilder();
sb.append(“Supported coins : ”).append(‘\n’);
for (CoinType coinType : supportedCoinTypes) {
sb.append(‘[’).append(coinType.code).append(‘)’).append(‘\n’);
}
String s = sb.toString();
Get Version
getVersion API returns its version. For Samsung Blockchain Keystore, it returns the versionName of the Keystore; and for the Ledger it returns the version of the Ledger Application running. If you need a different behavior depending on the version, you can call this API to branch.
HardwareWallet connectedHardwareWallet = hardwareWalletManager.getConnectedHardwareWallet();
String version = connectedHardwareWallet.getVersion();
Get Connection State
isConnected API returns the state that the HardwareWallet instance is connected. If connected, it returns as true. Otherwise, it returns as false.
if (hardwareWallet.isConnected()) {
hardwareWalletManager.disconnect(hardwareWallet);
}
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.