Links
Comment on page

Purge wallet

Erase wallet's public and private keys.
This command deletes all wallet data, including public and private key.
This operation is irreversible.
This command can be disabled if wallet was created during card personalization with special config flag, that protect wallets from purging.

Request

walletPublicKey <Data> The wallet's public key.
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".

Response

This command will return the SuccessResponse object in response.

Example

Swift
Kotlin
Java
JS (React Native)
JS (Cordova)
Dart
JSON-RPC
let walletPublicKey = card.wallets[0].publicKey //Will purge the first wallet
let cardId = card.cardId
tangemSdk.purgeWallet(walletPublicKey: walletPublicKey, cardId: cardId) { result in
switch result {
case .success:
print("The wallet deleted")
case .failure(let error):
print(error)
}
}
val walletPublicKey = card.wallets.first().publicKey //Will purge the first wallet
val cardId = card.cardId
tangemSdk.purgeWallet(
walletPublicKey = walletPublicKey,
cardId = cardId
) { result ->
when (result) {
is CompletionResult.Success -> {
runOnUiThread {
Log.d(TAG, "Wallet #1 has been successfully deleted")
}
}
is CompletionResult.Failure -> {
runOnUiThread {
Log.d(TAG, result.error)
}
}
}
}
byte[] walletPublicKey = card.getWallets().get(0).getPublicKey();
String cardId = card.getCardId();
tangemSdk.purgeWallet(walletPublicKey, cardId, null, result -> {
if (result instanceof CompletionResult.Success) {
SuccessResponse response = ((CompletionResult.Success<SuccessResponse>) result).getData();
Log.d(TAG, "Wallet #1 was successfully deleted");
} else if (result instanceof CompletionResult.Failure) {
TangemError error = ((CompletionResult.Failure<SuccessResponse>) result).getError();
Log.d(TAG, error.getCustomMessage());
}
return Unit.INSTANCE;
});
const walletPublicKey = card.wallets[0].publicKey;
const cardId = card.id;
TangemSdk.purgeWallet(walletPublicKey, cardId)
.then((result) => console.log(result))
.catch((err) => console.log(err));
var walletPublicKey = card.wallets[0].publicKey;
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.purgeWallet(walletPublicKey, cardId, initialMessage, callback);
// Request
{
"jsonrpc":"2.0",
"id":1,
"method":"purge_wallet",
"params":{
"walletPublicKey":"5130869115a2ff91959774c99d4dc2873f0c41af3e0bb23d027ab16d39de1348"
}
}
// Response
{
"jsonrpc":"2.0",
"result":{
"cardId":"c000111122223333"
},
"id":1
}