const sdk = new CryptumSdk({
environment: 'testnet',
apiKey: 'YOUR-API-KEY'
})
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..."
Generate a wallet for a blockchain protocol:
opts.protocol
(string) (required) - blockchain protocol supported:BITCOIN
,ETHEREUM
,BSC
,CELO
,STELLAR
,RIPPLE
,HATHOR
,CARDANO
,AVAXCCHAIN
,CHILIZ
,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',
// }
Generate a wallet for a blockchain protocol:
opts.protocol
(string) (required) - blockchain protocol supported:BITCOIN
,ETHEREUM
,BSC
,CELO
,STELLAR
,RIPPLE
,HATHOR
,CARDANO
,AVAXCCHAIN
,CHILIZ
,SOLANA
.opts.privateKey
(required)- (string) - most protocols (
BITCOIN
,ETHEREUM
,BSC
,CELO
,STELLAR
,RIPPLE
,HATHOR
,AVAXCCHAIN
,CHILIZ
,SOLANA
) require a private key string. - (object) - the
CARDANO
protocol requires an object containing two different private keysopts.privateKey.spendingPrivateKey
(string) - private key used for spending operationsopts.privateKey.stakingPrivateKey
(string) - private key used for staking operations
- (string) - most protocols (
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',
})
Generate a wallet address from xpub for a blockchain protocol:
opts.protocol
(string) (required) - blockchain protocol supported:BITCOIN
,ETHEREUM
,BSC
,CELO
,HATHOR
,CARDANO
,AVAXCCHAIN
,CHILIZ
.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
})