Keypair

createKeypair

- Creates an instance of WalletKeypar using password. This method is used to restore a wallet keypair. The Keypair contains some essential information, such as:

  • address

  • public key

  • key store

and so on, and it is used for pretty much any personalized operation that user can do using FindoraSdk

Parameters:

  • <string> - Password to be used to generate an encrypted KeyStore

Results:

  • Promise<WalletKeypar> - An instance of WalletKeypar

Example:

const password = "qsjEI%123";

// Create a wallet info object using given password
const walletPair = await Keypair.createKeypair(password);

getAddressByPublicKey

- Get wallet address by given public key Using this function user can retreive the wallet address by given public key

Parameters:

  • <string> - Public key

Results:

  • Promise<string> - A wallet address.

Example:

const pubkey = "qsjEI%123";
// Get wallet address by public key
const walletAddress = await Keypair.getAddressByPublicKey(pubkey);

getAddressPublicAndKey

- Create an instance of LightWalletKeypair using given wallet address. This method is used to create a light version of the WalletKeypar using given wallet address.The LightWalletKeypair contains two essential information:

  • address

  • public key

It's a light version of the WalletKeypar, containing only address and publickey

Parameters:

  • <string> - Wallet address

Results:

  • Promise<LightWalletKeypair> - An instance of LightWalletKeypair.

Example:

const address = "fra234xfde4";

// Create a LightWalletKeypair object using given address
const lightWalletKeypair = await Keypair.getAddressPublicAndKey(address);

getMnemonic

- Creates an array of Mnemonic phrases. This method is used to creates an array of Mnemonic phrases.

Parameters:

  • <number> - Desired length of mnemonic phrases. It can only be 12/15/18/21/24.

  • <string> - (optional) Default is en.

Results:

  • Promise<LightWalletKeypair> - An instance of LightWalletKeypair.

Example:

const desiredLength = 24;

// Create a wallet info object using given password
const mnemonic = await Keypair.getMnemonic(desiredLength);

restoreFromMnemonic

- Creates an instance of WalletKeypar using Mnemonic and password. This method is used to restore a wallet keypair. The Keypair contains some essential information, such as:

  • address

  • public key

  • key store

and so on, and it is used for pretty much any personalized operation that user can do using FindoraSdk

Parameters:

  • <string[]> - mnemonic words

  • <string> - Password to be used to generate an encrypted KeyStore

Results:

  • Promise<WalletKeypar> - An instance of WalletKeypar.

Example:

const password = "qsjEI%123";
const mnemonic = ["Apple", "Orange", "Banana"];

// Create a wallet info object using given Mnemonic and password
const walletPair = await Keypair.restoreFromMnemonic(mnemonic, password);

restoreFromPrivateKey

- Creates an instance of WalletKeypar using given private key and password. This method is used to restore a wallet keypair. The Keypair contains some essential information, such as:

  • address

  • public key

  • key store

and so on, and it is used for pretty much any personalized operation that user can do using FindoraSdk

Parameters:

  • <string> - Private key

  • <string> - Password to be used to generate an encrypted KeyStore

Results:

  • Promise<WalletKeypar> - An instance of WalletKeypar.

Example:

const password = "qsjEI%123";
const pkey = "XXXXXXXXXX";

// Create a wallet info object using given private key and password
const walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);

Last updated