Create wallet
Generate wallet's public and private keys.
Wallets can be generated by the card during production, according to the personalization config, or directly using the CreateWallet command.
CreateWallet command creates a wallet on the card. At this moment, by using a certified true random number generator (TRNG), the chip generates a random private key and then computes a corresponding public key from it. No one from outside the chip, including Tangem, can ever know what the private key is.
Each wallet on the card contains a pair of public and private keys. A public key is used to compute a unique address in the blockchain. A private key is used to sign transactions originating from this address. So only the owner of the private key can initiate the transfer of funds from this address.
Regardless of where and when the wallet was generated, neither Tangem nor anyone else has access to the private key. The private key cannot under any circumstances be declassified. This is one of the main advantages of the Tangem cards. In other words, whoever owns the private key owns the crypto funds.
You can generate up to 40 wallets on one card with different curves.
This method can be protected with a Passcode.

Request parameters

curve <EllipticCurve> Elliptic curve.
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 Card.Wallet (click to see more) object in response.

Example

Swift
Kotlin
Java
JS (React Native)
JS (Cordova)
Dart
JSON-RPC
1
let curve = EllipticCurve.secp256k1 //Check supported curves in Card.supportedCurves
2
let cardId = card.cardId
3
4
tangemSdk.createWallet(curve: curve, cardId: cardId) { result in
5
switch result {
6
case .success(let response):
7
let newWallet = response.wallet
8
print(newWallet)
9
case .failure(let error):
10
print(error)
11
}
12
}
Copied!
1
val curve = EllipticCurve.Secp256k1 //Check supported curves in Card.supportedCurves
2
val cardId = card.cardId
3
4
tangemSdk.createWallet(
5
curve = curve,
6
cardId = cardId
7
) { result ->
8
when (result) {
9
is CompletionResult.Success -> {
10
runOnUiThread {
11
Log.d(TAG, result.wallet)
12
}
13
}
14
is CompletionResult.Failure -> {
15
runOnUiThread {
16
Log.d(TAG, result.error)
17
}
18
}
19
}
20
}
Copied!
1
EllipticCurve curve = EllipticCurve.Secp256k1;
2
String cardId = card.getCardId();
3
4
tangemSdk.createWallet(curve, cardId, null, result -> {
5
if (result instanceof CompletionResult.Success) {
6
CreateWalletResponse response = ((CompletionResult.Success<CreateWalletResponse>) result).getData();
7
Log.d(TAG, response.getWallet());
8
} else if (result instanceof CompletionResult.Failure) {
9
TangemError error = ((CompletionResult.Failure<CreateWalletResponse>) result).getError();
10
Log.d(TAG, error.getCustomMessage());
11
}
12
return Unit.INSTANCE;
13
});
Copied!
1
import { EllipticCurve } from 'tangem-sdk-react-native';
2
3
const curve = EllipticCurve.Ed25519;
4
const isPermanent = true;
5
const cardId = card.id;
6
7
TangemSdk.createWallet(curve, isPermanent, cardId)
8
.then((result) => console.log(result))
9
.catch((err) => console.log(err));
Copied!
1
var curve = 'Ed25519';
2
var isPermanent = true;
3
var cardId = card.cardId;
4
var initialMessage = {"body": "body", "header": "header"};
5
var callback = function (response, error) {
6
if (error) {
7
alert({ "error": error });
8
} else {
9
alert({"response": response});
10
}
11
};
12
13
TangemSdk.createWallet(curve, isPermanent, cardId, initialMessage, callback);
Copied!
1
Copied!
1
// Request
2
{
3
"jsonrpc":"2.0",
4
"id":1,
5
"method":"create_wallet",
6
"params":{
7
"curve":"secp256r1"
8
}
9
}
10
11
// Response
12
{
13
"jsonrpc":"2.0",
14
"result":{
15
"cardId":"c000111122223333",
16
"wallet":{
17
"publicKey":"5130869115a2ff91959774c99d4dc2873f0c41af3e0bb23d027ab16d39de1348",
18
"curve":"secp256r1",
19
"settings":{
20
"isPermanent":true
21
},
22
"totalSignedHashes":10,
23
"index":1
24
}
25
},
26
"id":1
27
}
Copied!