Comment on page
Set Access Code
Protects the whole card even from reading
If Access code is set on the card, all commands, including Scan Card, will require to sumbit this code. So if the Access code is lost, there is no way to recover the data or even retrieve the public key. Access codes may be enabled or disabled during card configuration at the factory. Also, it’s possible to prohibit removing the access code from the card once it’s set.
Access code can consist of letters, digits or special symbols and can be any length.
Access code can be set only if
card.settings.isSettingAccessCodeAllowed
istrue
.accessCode <String> [optional]
Access code 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".
Swift
Kotlin
Java
JS (React Native)
JS (Cordova)
Dart
JSON-RPC
let accessCode = "123456" //This parameter can be omitted. Tangem sdk will request the code from the user automatically
let cardId = card.cardId
tangemSdk.setAccessCode(accessCode, cardId: cardId) { result in
switch result {
case .success:
print("The access code was set")
case .failure(let error):
print(error)
}
}
val accessCode = "123456" //This parameter can be omitted. Tangem sdk will request the code from the user automatically
val cardId = card.cardId
tangemSdk.setAccessCode(
accessCode = accessCode,
cardId = cardId
) { result ->
when (result) {
is CompletionResult.Success -> {
runOnUiThread {
Log.d(TAG, "The access code was set")
}
}
is CompletionResult.Failure -> {
runOnUiThread {
Log.d(TAG, result.error)
}
}
}
}
String accessCode = "1234qwerty"; // if omitted, the user will be prompted by TangemSDK to enter it
String cardId = card.getCardId();
tangemSdk.setAccessCode(accessCode, cardId, null, result -> {
if (result instanceof CompletionResult.Success) {
SuccessResponse response = ((CompletionResult.Success<SuccessResponse>) result).getData();
Log.d(TAG, "The access code was set");
} else if (result instanceof CompletionResult.Failure) {
TangemError error = ((CompletionResult.Failure<SuccessResponse>) result).getError();
Log.d(TAG, error.getCustomMessage());
}
return Unit.INSTANCE;
});
const accessCode = 'ABCDEF';
const walletPublicKey = card.wallets[0].publicKey;
const cardId = card.id;
TangemSdk.setAccessCode(accessCode, cardId)
.then((result) => console.log(result))
.catch((err) => console.log(err));
var accessCode = '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.setAccessCode(accessCode, cardId, initialMessage, callback);
// Request
{
"jsonrpc":"2.0",
"id":1,
"method":"set_accesscode",
"params":{
"accessCode":"ABCDEFGH"
}
}
// Response
{
"jsonrpc":"2.0",
"result":{
"cardId":"c000111122223333"
},
"id":1
}
Last modified 2yr ago