Links
🗂

Blockchain wallets

Blockchain wallets creation using the SDK
const sdk = new CryptumSdk({
environment: 'testnet',
apiKey: 'YOUR-API-KEY'
})
sdk.wallet.generateWallet(opts)
Generate a wallet for a blockchain protocol:
  • opts.protocol (string) (required) - blockchain protocol supported: BITCOIN, ETHEREUM, BSC, CELO, STELLAR, RIPPLE, HATHOR, CARDANO, AVAXCCHAIN, SOLANA.
  • opts.mnemonic (string) (optional) - mnemonic string to generate private and public keys.
  • opts.derivation (object) (optional) - derivation object (BIP44 derivation path).
  • opts.derivation.account (number) (optional) - derivation account index.
  • opts.derivation.change (number) (optional) - derivation change index.
  • opts.derivation.address (number) (optional) - derivation address index.
Example:
// generate random wallet for blockchain protocol
const wallet = await sdk.wallet.generateWallet({ protocol: 'STELLAR' })
​
// or using an existing mnemonic
const wallet = await sdk.wallet.generateWallet({
protocol: 'ETHEREUM',
mnemonic: '<words>...',
derivation: { account: 10, address: 2 }
})
console.log(wallet)
// Wallet {
// privateKey: '...',
// publicKey: '...',
// xpub: '...',
// protocol: 'ETHEREUM',
// }
The mnemonic is optional, and automatically generated at random when generating a wallet. If necessary, you can insert your own mnemonic.
sdk.wallet.generateRandomMnemonic(strength)
Generate random mnemonic (words) to generate wallets.
  • strength (number)(optional) - strength number.
const mnemonic = sdk.wallet.generateRandomMnemonic()
console.log(mnemonic)
// "window license ordinary apple toilet wrestle disease sudden until armor wealth room..."
​
sdk.wallet.generateWalletFromPrivateKey(opts)
Generate a wallet for a blockchain protocol:
  • opts.protocol (string) (required) - blockchain protocol supported: BITCOIN, ETHEREUM, BSC, CELO, STELLAR, RIPPLE, HATHOR, CARDANO, AVAXCCHAIN,SOLANA.
  • opts.privateKey (required)
    • (string) - most protocols (BITCOIN, ETHEREUM, BSC, CELO, STELLAR, RIPPLE, HATHOR, AVAXCCHAIN,SOLANA) require a private key string.
    • (object) - the CARDANO protocol requires an object containing two different private keys
      • opts.privateKey.spendingPrivateKey (string) - private key used for spending operations
      • opts.privateKey.stakingPrivateKey (string) - private key used for staking operations
Example:
// using an existing private key
const wallet = await sdk.wallet.generateWalletFromPrivateKey({
privateKey: '0x...',
protocol: 'BSC',
})
​
// for the cardano network
const cardanoWallet = await sdk.wallet.generateWalletFromPrivateKey({
privateKey: {
spendingPrivateKey: '0x...',
stakingPrivateKey: '0x...',
},
protocol: 'CARDANO',
})
sdk.wallet.generateWalletAddressFromXpub(opts)
Generate a wallet address from xpub for a blockchain protocol:
  • opts.protocol (string) (required) - blockchain protocol supported: BITCOIN, ETHEREUM, BSC, CELO, HATHOR, CARDANO,AVAXCCHAIN.
  • opts.xpub (string) (required) - xpub string.
  • opts.address (number) (required) - address index.
Example:
const walletAddress = await sdk.wallet.generateWalletAddressFromXpub({
xpub: 'xpub...',
protocol: 'BSC',
address: 0
})