Comment on page

Set Passcode

Protects wallets
Passcode protects signing and operations that can alter security parameters. Passcode may be enabled or disabled during card configuration at the factory. Also, it’s possible to prohibit removing the passcode from the card once it’s set.
Passcode can consist of letters, digits or special symbols and can be any length.
Passcode can be set only if card.settings.isSettingPasscodeAllowedistrue.


passcode <String> [optional] Passcode to set. If empty, user will be prompted to enter code before operation.
cardId <String> CID, Unique Tangem card ID number.
initialMessage <Message> [optional] This message will be shown in the NFC session dialog. Default: "Tap the card to your phone exactly as it shown above".


This command will return the SuccessResponse (click to see more) object in response.


JS (React Native)
JS (Cordova)
let passcode = "123456" //This parameter can be omitted. Tangem sdk will request the code from the user automatically
let cardId = card.cardId
tangemSdk.setPasscode(passcode, cardId: cardId) { result in
switch result {
case .success:
print("The passcode was set")
case .failure(let error):
val passcode = "123456" //This parameter can be omitted. Tangem sdk will request the code from the user automatically
val cardId = card.cardId
passcode = passcode,
cardId = cardId
) { result ->
when (result) {
is CompletionResult.Success -> {
runOnUiThread {
Log.d(TAG, "The passcode was set")
is CompletionResult.Failure -> {
runOnUiThread {
Log.d(TAG, result.error)
String passcode = "123456"; // if omitted, the user will be prompted by TangemSDK to enter it
String cardId = card.getCardId();
tangemSdk.setPasscode(passcode, cardId, null, result -> {
if (result instanceof CompletionResult.Success) {
SuccessResponse response = ((CompletionResult.Success<SuccessResponse>) result).getData();
Log.d(TAG, "The passcode was set");
} else if (result instanceof CompletionResult.Failure) {
TangemError error = ((CompletionResult.Failure<SuccessResponse>) result).getError();
Log.d(TAG, error.getCustomMessage());
return Unit.INSTANCE;
const passCode = 'ABCDEF';
const cardId =;
TangemSdk.setPassCode(passCode, cardId)
.then((result) => console.log(result))
.catch((err) => console.log(err));
var passCode = 'ABCDEF';
var cardId = card.cardId;
var initialMessage = {"body": "body", "header": "header"};
var callback = function (response, error) {
if (error) {
alert({ "error": error });
} else {
alert({"response": response});
TangemSdk.setPassCode(passCode, cardId, initialMessage, callback);
// Request
// Response