API Implementation

Samsung Blockchain Keystore API Level

Samsung Blockchain Keystore API Level plays a key role to ensure that the required API level of Samsung Blockchain Keystore on a user’s device is properly installed to support the API that your Android app tries to call.

For example, if your Android app is trying to implement a new Samsung Blockchain Keystore API that requires “API Level 2”, your Android app will need to check whether Samsung Blockchain Keystore app installed on user’s device also supports API Level 2. If a user’s app supports API Level 1, then your app will need to guide users to update Samsung Blockchain Keystore app to the latest version. Users can be directed to the update page in Galaxy Store. Otherwise, there will be a runtime exception due to API Level Exception when calling APIs with level higher than the level supported by the user’s version.

The API Level for each API will be mentioned in the Javadoc, under “Since” title, and developers can call “getKeystoreApiLevel API” to check the current API Level on the user’s device. Your Android app will need to check the API Level whenever needed – it may be at the beginning of running Samsung Blockchain Keystore app or every time your app calls an API.

public void getKeystoreApiLevel() {
	int keystoreApiLevel = ScwService.getInstance().getKeystoreApiLevel();
	boolean isKeystoreApiSupported = keystoreApiLevel > 0;
}

Get Instance

ScwService.getInstance( ) will need to be used to call any of the APIs provided by Samsung Blockchain Keystore. If Samsung Blockchain Keystore is supported on the device, an instance will be returned. If it is not available on the device, then null will be returned. If null is returned, it means Samsung Blockchain Keystore is not supported on the user’s device. A different keystore or a wallet needs to be used.

ScwService scwServiceInstance = ScwService.getInstance();

Get Seed Hash

getSeedHash API aims to help developers distinguish two things:

(1) Check whether user has set up Samsung Blockchain Keystore.

(2) Check whether Root Seed (recovery phrase) has been changed or not.

Every time a new Root Seed (or a wallet) is created or restored, the seed hash in a String value will be changed. Actually, this is not the preimage of the real seed, but a pseudo hash value. So, it is not possible to calculate the real seed with the pseudo one.

It is strongly recommended for the application to cache the returned hash value to reduce the number of times to check the derived address’s validity. If the returned value is same as cached, the derived addresses are still valid, so the application keeps using these addresses. Otherwise, the application should refresh the addresses from new seed with getAddressList() or getExtendedPublicKeyList() API. Whenever the application starts, it needs to call getSeedHash().

In case that the returned value is a zero-length string, it means that there is no wallet in the Samsung Blockchain Keystore. So, the application UI needs to guide users to jump to Samsung Blockchain Keystore to create a wallet with ScwDeepLink.MAIN deeplink.

public void getSeedHash() {
    String seedHash = ScwService.getInstance().getSeedHash();
    boolean initialized =  (seedHash != null && seedHash.length() > 0);
    }

Check Mandatory App Update

checkForMandatoryAppUpdate API is to help developers check if a user must update Samsung Blockchain Keystore. Because Samsung Blockchain Keystore handles only one task at a time, make sure to NOT call the checkForMandatoryAppUpdate API in the background as it may cause other API calls or requests to be cancelled.

If a mandatory app update is needed, users can be directed to the Galaxy Store using a deeplink, ScwDeepLink.GALAXY_STORE. Otherwise, users will see the mandatory app update popups during an operation process, such as signing a transaction, and will need to update Samsung Blockchain Keystore before proceeding.

Note: ScwService.ScwCheckForMandatoryAppUpdateCallback will need to be implemented correspondingly .

ScwService.ScwCheckForMandatoryAppUpdateCallback callback =
    new ScwService.ScwCheckForMandatoryAppUpdateCallback() {
                @Override
                    public void onMandatoryAppUpdateNeeded(boolean needed) {
                        if(needed){
                            startDeepLink(ScwDeepLink.GALAXY_STORE);
                        }
                    }
                };
                   
    ScwService.getInstance().checkForMandatoryAppUpdate(callback);
  • How to handle the returned value

    A Boolean needed value of whether a mandatory update is needed or not will be returned.

    If needed, developers will need to guide users to go to Samsung Blockchain Keystore app page in Galaxy Store to update.

Is Root Seed Backed Up

isRootSeedBackedUp API helps developers check if there is a backup of Root Seed. Since a user can create a wallet without a backup of Root Seed, developers can advise the user to make Root Seed backup.

If a backup of Root Seed is needed, the users will be directed to the page which backs up the mnemonic phrases in the Samsung Blockchain Keystore using a deep link, ScwDeepLink.BACKUP_WALLET.

Boolean isBackedUp = ScwService.getInstance().isRootSeedBackedUp();

        if (!isBackedUp) {
            startDeepLink(ScwDeepLink.BACKUP_WALLET);
        }
  • How to handle the returned value

    The result of Root Seed backup will be returned in a Boolean type.

Get Supported Coins

getSupportedCoins API is used to find out which type of cryptocurrencies are supported, in case there is a different logic that developers must implement for different cryptocurrencies. It is returned in an int array of standard coin types according to BIP standard – for example, 60 for Ethereum.

int[] supportedCoins = ScwService.getInstance().getSupportedCoins();
                
        StringBuilder sb = new StringBuilder();
        sb.append("Supported coins").append('\n');
        for (int i = 0; i < supportedCoins.length; i++ ) {
            sb.append('[').append(i).append("] ").append(supportedCoins[i]).append('\n');
        }
            
        String s = sb.toString();

Get HD Path

getHdPath API helps developers derive HD path for a specified coin type. This API can be used as a parameter when deriving an address and requesting to sign a transaction. Note that UTXO-based cryptocurrency, such as Bitcoin will NOT be supported for this API.

No callback will be needed for this API as HD path in String type will be returned immediately.

//Derive HD path for the cryptocurrency that your app supports

    String ethereumHdPath = ScwService.getHdPath(ScwCoinType.ETH, 0);
            
    String klaytnHdPath = ScwService.getHdPath(ScwCoinType.KLAY, 0);
            
    String tronHdPath = ScwService.getHdPath(ScwCoinType.TRON, 0);
    
    String stellarHdPath = ScwService.getHdPath(ScwCoinType.XLM, 0);
            

There are two parameters needed: coin type and address index.

  • Coin Type

    Use ScwCoinType class to specify the cryptocurrency that your app uses.

  • Address Index

    Address Index is like an account number. It is recommended to use 0 as the default address index. Increasing the address index will generate a different account. For example, if you need another Ethereum account, then you can increase this address index to 1.

    If you need just one address for your service, then make sure to use the same coin type and same address index throughout your service so that user does not get confused with multiple addresses.

  • Examples

    The returned value will be HD path in a String format. This HD path will be needed for getAddressList API and signing cryptocurrency APIs.

    ScwService.getHdPath(ScwCoinType.ETH, 0) will return “m/44’/60’/0’/0/0”

    ScwService.getHdPath(ScwCoinType.ETH, 1) will return “m/44’/60’/0’/0/1”

    ScwService.getHdPath(ScwCoinType.KLAY, 0) will return “m/44’/8217’/0’/0/0”

    ScwService.getHdPath(ScwCoinType.TRON, 0) will return “m/44’/195’/0’/0/0”

    ScwService.getHdPath(ScwCoinType.XLM, 0) will return “m/44’/148’/0’”

  • For more details on HD path

    Refer to Key Management section in Understanding Keystore. You can find how HD path is used in Samsung Blockchain Keystore.

Get a list of Addresses

getAddressList API allows developers to request to get a list of addresses that correspond to a list of HD Paths. A list of the HD Path, compatible with BIP-44 needs to be passed on to bring the addresses. The depth of HD path should be between 3 and 6.

Also, ScwService.ScwGetAddressListCallback will need to be implemented correspondingly.

ScwService.ScwGetAddressListCallback callback = 
    new ScwService.ScwGetAddressListCallback() {
            @Override
            public void onSuccess(List<String> addressList) {
                        
            }
    
            @Override
            public void onFailure(int errorCode, String errorMessage) {
                //handle errors
    
            }
        };

String hdPath =  ScwService.getHdPath(ScwCoinType.ETH, 0);
    
    ArrayList<String> hdPathList = new ArrayList<>();
    hdPathList.add(hdPath);
    
    ScwService.getInstance().getAddressList(callback, hdPathList);
    
  • Hierarchical Deterministic Path (HD Path) Examples

    hdPath for Ethereum: m/44'/60'/0'/0/0

    hdPath for Bitcoin: m/44'/0'/0'/0/0

    If you are unsure about what HD path is, then you can generate HD path with getHdPath API. (Except for Bitcoin)

  • How to handle the returned value

    The returned value will be a list of addresses in a List** format. Each address will correspond to the HD path in the ArrayList.

  • Minimize calling getAddressList API by checking Seed Hash value

    To avoid calling getAddressList API as much as possible, please utilize getSeedHash API to check whether the Root Seed has been changed or not, since different Seed Hash value implies that the corresponding address has also been updated.

Get a list of Extended Public Keys

getExtendedPublicKeyList API allows developers to request to get a list of extended Public Keys that correspond to a list of HD Paths. A list of the HD Path, compatible with BIP-44 needs to be passed on to bring the public key. The depth of path should be between 3 and 6.

Take note that the ScwService.ScwGetExtendedPublicKeyListCallback will need to be implemented correspondingly.

ScwService.ScwGetExtendedPublicKeyListCallback callback = 
    new ScwService.ScwGetExtendedPublicKeyListCallback() {
            @Override
            public void onSuccess(List<byte[]> extendedPublicKeyList) {
                        
            }
    
            @Override
            public void onFailure(int errorCode, String errorMessage) {
                //handle errors
    
            }
        };
    
String hdPath =  ScwService.getHdPath(ScwCoinType.ETH, 0);
    
    ArrayList<String> hdPathList = new ArrayList<>();
    hdPathList.add(hdPath);

    ScwService.getInstance().getExtendedPublicKeyList(callback, hdPathList);
  • Hierarchical Deterministic Path (HD Path) Examples

    hdPath for Ethereum: m/44'/60'/0'/0/0

    hdPath for Bitcoin: m/44'/0'/0'/0/0

  • How to handle the returned value

    The returned value will be List <byte[]> that corresponds to each HD path requested in the ArrayList. Each byte array is composed of 33 bytes of compressed public key and 32 bytes of chain code. You can derive the child public key based on this data. Note that you need to derive the address of the compressed public key or call getAddressList API to get the address.

  • Minimize calling getExtendedPublicKeyList API by checking Seed Hash value

    Use getSeedHash API to check whether the Root Seed has been changed or not, since different Seed Hash value implies that corresponding public keys have also been updated.

Sign a Transaction

There are seven APIs that support signing cryptocurrency transactions: Ethereum, Personal Sign Message in Ethereum, Bitcoin, Klaytn, Tron, Personal Sign Message in Tron, and Stellar.

Note: Only signing a transaction is included in the Samsung Blockchain Keystore scope.

1. signEthTransaction API

signEthTransaction API as the name implies, sends a request to Samsung Blockchain Keystore to sign an Ethereum Transaction. Likewise, ScwService.ScwSignEthTransactionCallback will need to be implemented.

ScwService.ScwSignEthTransactionCallback callback = 
		new ScwService.ScwSignEthTransactionCallback() {
				@Override
				public void onSuccess(byte[] signedEthTransaction) {
							
				}
		
				@Override
				public void onFailure(int errorCode, String errorMessage) {
					//handle error
							
				}
			};
		
		
		
			String toAddress = "0xe7425ee1bc64ab7c51ce3617cb83e76fd545f1a9";
			String ethAmount = "123.456789";
			String ethGasPrice = "12000000000";
			String ethGasLimit = "21000";
			String data = "";
            Long chainId = 1;
		
		
		String hdPath =  ScwService.getHdPath(ScwCoinType.ETH, 0);
		
		
		byte[] encodedUnsignedEthTx = createRawTransaction(toAddress, ethAmount, ethGasPrice, ethGasLimit, data);
		
		private byte[] createRawTransaction(param1, param2, …){
		
			  //Implement your code here
		
		}
		
		ScwService.getInstance().signEthTransaction(callback, encodedUnsignedEthTx, hdPath, chainId);
		

The parameters to take note are as follows:

  • encodedUnsignedEthTx : a byte array of an RLP-encoded unsigned Ethereum raw transaction.

  • hdPath : HD Path that corresponds to the address linked to your Android app that also corresponds to the private key which is used for signing

  • chainId : chain ID to prevent replay attacks between different chain. For EIP1559 transaction, chainId should be null.

  • How to handle the returned value

    The signed transaction will be returned in a byte array type in a RLP-encoded format.

2. signEthPersonalMessage API

signEthPersonalMessage API can be used to request to Samsung Blockchain Keystore to sign a message in Ethereum. ScwService.ScwSignEthPersonalMessageCallback will need to be implemented.

ScwService.ScwSignEthPersonalMessageCallback callback = 
		new ScwService.ScwSignEthPersonalMessageCallback() {
				@Override
				public void onSuccess(byte[] signedPersonalMessage) {
							
				}
		
				@Override
				public void onFailure(int errorCode, String errorMessage) {
					//handle error
							
				}
			};
		
		
		
		String hdPath =  ScwService.getHdPath(ScwCoinType.ETH, 0);
		
		byte[] unSignedMsg = "To sign up, please sign this message.".getBytes();
		
		ScwService.getInstance().signEthPersonalMessage(callback, unSignedMsg, hdPath);
		

The parameters to take note are as follows:

  • unSignedMsg – a byte array of raw message to be signed by Samsung Blockchain Keystore. The "\u0019Ethereum Signed Message:\n" prefix will be added by Samsung Blockchain Keystore, so your Android app should not include the prefix in the message.

  • hdpath : HD Path that corresponds to the address linked to your Android app that also corresponds to the private key which is used for signing

  • How to handle the returned value:

    The type of return is a byte array of signed message based on R, S, V (values for a transaction’s signature) respectively.

3. signBtcTransaction API

signBtcTransaction API can be used to create a request to Samsung Blockchain Keystore to sign a Bitcoin transaction. The ScwService.ScwSignBtcTransactionCallback will need to be implemented.

ScwService.ScwSignBtcTransactionCallback callback = 
		new ScwService.ScwSignBtcTransactionCallback() {
				@Override
				public void onSuccess(byte[] signedBtcTransaction) {
							
				}
		
				@Override
				public void onFailure(int errorCode, String errorMessage) {
					//handle error
							
				}
			};
		
		List<UTXO> utxos = new ArrayList<>();
		ArrayList<String>  inputHdPathList = new ArrayList<>();
		String changeHdPath = "m/44'/0'/0'/0/0";
		String inputHdPath1 = "m/44'/0'/0'/0/0";
		String inputHdPath2 = "m/44'/0'/0'/0/1";
		
		utxos.add(getUnspentOutputs(inputHdPath1));
		utxos.add(getUnspentOutputs(inputHdPath2));
		TransactionExtended unsignedtx = makeUnsignedTransaction(networkParams, utxos, to, value, fee);		
		for (int i = 0; i < unsignedTx.getInputs().size(); i++) {
				String inputHdPath = unsignedTx.getInputs().getHdPath(i);
				inputHdPathList.add(inputHdPath);
			 }

		private Transaction makeUnsignedTransaction ( NetworkParameters networkParams, List<UTXO> utxos,
		 String to, long value, long fee){
			//Make unsigned transaction among unspent outputs to spend value with fee
			//Implement your code here
		}

		ScwService.getInstance().signBtcTransaction(callback, transaction, inputHdPathList, changeHdPath);
		

The parameters to take note are as follows:

  • transaction A byte array of a serialized unsigned Bitcoin transaction to be signed by Samsung Blockchain Keystore.

  • inputHdPathList : A list of HD Path that corresponds to the addresses linked to the transaction inputs in transaction. This list also corresponds to the private key which is used for signing. BIP-44, 49, 84 are supported and coin type “1” in HD Path can be used for Bitcoin test network. Parameter Check: Samsung Blockchain Keystore will verify the requested transaction using TransactionInput in transaction and inputHdPathList. Each TransactionInput should correspond to an HD path in inputHdPathList. If there are multiple TransactionInput, then corresponding inputHdPathList and TransactionInputs should be listed in the same order.

  • changeHdPath : If there is a return change, then include the HD Path that corresponds to the change address. If the change address is not needed, then this value should be null.

  • How to handle the returned value:

    The signed transaction will be returned in a byte array type.

4. signKlayTransaction API

signKlayTransaction API can be used to request to Samsung Blockchain Keystore to sign a Klaytn transaction. ScwService.ScwSignKlayTransactionCallback will need to be implemented.

ScwService.ScwSignKlayTransactionCallback callback = 
		new ScwService.ScwSignKlayTransactionCallback() {
				@Override
				public void onSuccess(byte[] signedKlayTransaction) {
							
				}
		
				@Override
				public void onFailure(int errorCode, String errorMessage) {
					//handle error
							
				}
			};
		
		
		String hdPath =  ScwService.getHdPath(ScwCoinType.KLAY, 0);
		
		byte[] unSignedTransaction = getUnsignedTx();
		int klaytnChainId = 1001;
		
		
		ScwService.getInstance().signKlayTransaction(callback,  unSignedTransaction, hdPath, klaytnChainId);
		

The parameters to take note are as follows:

  • unSignedTransaction a byte array of raw transaction to be signed by Samsung Blockchain Keystore. It is same as the sigRLP value mentioned in Klaytn official document.
  • hdPath - HD Path that corresponds to the public key linked to your Android app that also corresponds to the private key which is used for signing.
  • klaytnChainId – The Klaytn network ID or the integer to identify the network.
    "8217" is Klaytn Cypress Mainnet and "1001" is Klaytn Baobab Testnet
  • How to handle the returned value:
    The signed transaction will be returned in a byte array type in a RLP-encoded format.

5. signTrxTransaction API

signTrxTransaction API can be used to request to Samsung Blockchain Keystore to sign a Tron transaction. ScwService.ScwSignTrxTransactionCallback will need to be implemented.

ScwService.ScwSignTrxTransactionCallback callback = 
		new ScwService.ScwSignTrxTransactionCallback() {
				@Override
				public void onSuccess(byte[] signedTrxTransaction) {
					 //handle signed Tron transaction
				}
		
				@Override
				public void onFailure(int errorCode, String errorMessage) {
					//handle error
							
				}
			};
		
		
		
		
		
		String hdPath = ScwService.getHdPath(ScwCoinType.TRON, 0);
		String from = “TDCMWoSbAfcegQqNUaRNjGhY4tAbdCmdwi”
		String to = “TQ6pM81JDC2GhrUoNYtZGvPc7SvyqcemEu”;
		int amount = 2;
		
		byte[] unsignedTransaction = createUnsignedTransaction(hdPath from, to, amount);
		
		private byte[] createUnsignedTransaction (param1, param2, …){
				//Implement your code here
		
		}
		
		
		ScwService.getInstance().signTrxTransaction(callback, unsignedTransaction, hdPath);
		
		

The parameters to take note are as follows:

  • unSignedTransaction a byte array of raw Tron transaction to be signed by Samsung Blockchain Keystore.

  • hdPath - HD Path that corresponds to the public key linked to your Android app that also corresponds to the private key which is used for signing.

  • How to handle the returned value:

    Signed transaction will be returned in a byte array.

6. signTrxPersonalMessage API

signTrxPersonalMessage API can be used to request to the Samsung Blockchain Keystore to sign a message in Tron. The ScwService.ScwSignTrxPersonalMessageCallback will need to be implemented.

ScwService.ScwSignTrxPersonalMessageCallback callback = 
    new ScwService.ScwSignTrxPersonalMessageCallback() {
                @Override
                public void onSuccess(byte[] signedPersonalMessage) {
                    
                }

                @Override
                public void onFailure(int errorCode, String errorMessage) {
                    //handle error
                    
                }
            };



    String hdPath =  ScwService.getHdPath(ScwCoinType.TRON, 0);
    byte[] unSignedMsg = "To sign up, please sign this message.".getBytes();
    ScwService.getInstance().signTrxPersonalMessage(callback, unSignedMsg, hdPath);

The parameters to take note are as follows:

  • unSignedMsg: A byte array of raw message to be signed by Samsung Blockchain Keystore. A "\u0019TRON Signed Message:\n32" prefix will be added by Samsung Blockchain Keystore, so your Android app should not include the prefix in the message.

  • hdpath: HD Path that corresponds to the address linked to your Android app that also corresponds to the private key which is used for signing

  • How to handle the returned value: The type of return is a byte array of signed message based on values for a transaction’s signature - R, S, V respectively.

7. signXlmTransaction API

signXlmTransaction API can be used to request to the Samsung Blockchain Keystore to sign a Stellar transaction. The ScwService.ScwSignXlmTransactionCallback will be needed to be implemented.

ScwService.ScwSignXlmTransactionCallback callback = 
   new ScwService.ScwSignXlmTransactionCallback() {
                @Override
                public void onSuccess(byte[] signedXlmTransaction) {
                    //handle signed Stellar transaction
                }

                @Override
                public void onFailure(int errorCode, String errorMessage) {
                    //handle error
                    
                }
            };


   String recipientAccount = “GAY5DORARBD5L3FBBWUHXKCIV7VCMQICSLLJ7GYR4664AV4MXTX2FH4O”;
   String amount = “100”;

   PaymentOperation operation = new PaymentOperation.Builder(recipientAccount, asset, amount).build();

   String hdPath = ScwService.getHdPath(ScwCoinType.XLM, 0);
   ArrayList<String> hdPathList = new ArrayList<>();
   hdPathList.add(hdPath);

   String sourceAccount = “GB7ZVIYDVSWW3CTFJ2V3OPROAHGBUOMEBWIB55XIEII3AQ6523PG4LM5”;
   String memo = "hello12347";

   byte[] unsignedTransaction = createUnsignedTransaction(sourceAccount, operation, memo, networkID);

   private byte[] createUnsignedTransaction (param1, param2, …){
   //Implement your code here
   // include NetworkID, EnvelopeType (ENVELOPTE_TYPE_TX), and XDR-encoded Transaction


   }


ScwService.getInstance().signXlmTransaction(callback, unsignedTransaction, hdPathList);

		

The parameters to take note are as follows:

  • unsignedTransaction – a byte array of raw transaction to be signed by Samsung Blockchain Keystore. It is the same as the signature base, which includes NetworkID, EnvelopeType, and XDR-encoded Transaction.

  • hdPathList : A list of HD Path that corresponds to the addresses linked to your Android app that also corresponds to the private key which is used for signing.

  • How to handle the returned value:

    The signed transaction will be returned in a byte array. Developers can use Base64 encoding to implement this result into EnvelopeXDR, which can derive the Transaction that can be submitted to the network.

Is Reboot Authentication Required

The isRebootAuthenticationRequired API allows you to check whether PIN authentication is required after reboot.

Some keystore API calls can require PIN authentication after device reboot. These calls are successful only after the user enters their blockchain keystore PIN at the prompt. The isRebootAuthenticationRequired() method allows you to determine whether accessing the keystore API requires PIN authentication.

Boolean isRebootAuthenticationRequired = ScwService.getInstance().isRebootAuthenticationRequired();

        if(isRebootAuthenticationRequired) {
        // User prompted for PIN authentication
        }
        else {
        // User not prompted for PIN authentication   
        }
		

• Handling the returned value: The isRebootAuthenticationRequired() method returns a Boolean value.

Go to Samsung Blockchain Keystore Settings

Samsung Blockchain Keystore provides a user-friendly setup page for the first time users and a Settings page for existing users. Developers can easily jump to Samsung Blockchain Keystore Settings by using a deeplink, ScwDeepLink.MAIN.. There are two purposes of calling the Samsung Blockchain Keystore Main activity.

  1. Setup Samsung Blockchain Keystore for first time users

    After calling getSeedHash API, if the wallet is not created, a zero length value will be returned. This is when your Android app should call Samsung Blockchain Keystore Settings via a deep link as shown below. Samsung Blockchain Keystore will check if a user needs to set up a new wallet and if needed, will lead to a setup page. After the activity is finished, your Android app should call the getSeedHash API, once more, to make sure that the wallet has been created and the corresponding Seed Hash value is returned.

  2. Samsung Blockchain Keystore Settings for existing users

    For existing users, when Samsung Blockchain Keystore Settings is called, a user will see a list of menu related to Samsung Blockchain Keystore management. Features include changing the PIN, removing the wallet, checking a recovery phrase to back up the wallet, enabling/disabling Fingerprint as an authentication method, or changing alarm notifications settings. More information about the Samsung Blockchain Keystore, such as Notices, Terms and Conditions, and App Information can be also found here.

A sample code for calling Samsung Blockchain Keystore via a deeplink is as follows.

    Uri uri = Uri.parse(ScwDeepLink.MAIN);
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(uri);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mContext.startActivity(intent);

*Do NOT call startActivityForResult(intent) as no results will be returned. Make sure to use startActivity(intent) instead.

Handling Error Codes

In addition to general error codes, the following are some special cases that developers may want to look out for.

  • Mandatory Update is needed

  • Samsung Blockchain Keystore was removed due to user entering wrong PIN more than N times

  • API Key is invalid

The popups above will be shown from Samsung Blockchain Keystore app, though the Samsung Blockchain Keystore will still return corresponding error codes. In the Mandatory Update error case, the user will see a popup with a link to Galaxy Apps Store page to update Samsung Blockchain Keystore. If it was reset, due to entering a wrong PIN more than N times, then the user will need to create or import the wallet via Samsung Blockchain Keystore service again.

It is recommended that developers call checkForMandatoryAppUpdate API before calling other APIs, to check whether a mandatory app update is needed. For this API, no UI or popup will be shown from Samsung Blockchain Keystore.

Upon integration, developers may receive an “ERROR_PACKAGE_SIGNATURE_VERIFICATION_FAILED” error. In this case, developers can turn on Developer Mode to skip the app verification stage. Yet, developers will need to implement proper App ID, officially issued by the Samsung Blockchain Keystore team before launching your Android app in the market.

public interface ScwErrorCode {
        int ERROR_MANDATORY_APP_UPDATE_NEEDED = -8;
        int ERROR_PACKAGE_SIGNATURE_VERIFICATION_FAILED = -11;
        int ERROR_WALLET_RESET = -12;
        int ERROR_CHECK_APP_VERSION_FAILED = -15;
        int ERROR_TNC_NOT_AGREED = -6;
        }

Please refer to the ScwErrorCode class in JavaDoc for more details on error codes.

Deep links to Samsung Blockchain Keystore and deep link to update Samsung Blockchain Keystore app in Galaxy Store are provided. Developers can implement the links below to direct users to go to the main page and back up Root Seed page in Samsung Blockchain Keystore Settings directly. Deep link to Galaxy Store can be used when user needs to update Samsung Blockchain Keystore app.

Features Deeplink
Main page ScwDeepLink.MAIN
Galaxy Apps Store ScwDeepLink.GALAXY_STORE
Backup wallet ScwDeepLink.BACKUP_WALLET