LogoLogo
Cryptum.ioGitHub
  • 🌐Cryptum
    • What is Cryptum
    • DeFi Market
    • Ecosystem
      • Bitcoin
      • Ethereum
      • Polygon
      • Avalanche C-Chain
      • BNB Chain
      • Cardano
      • Celo
      • Hathor
      • Solana
      • Stellar
      • XRP Ledger
      • Stratus
      • Hyperledger Besu
  • 👝Products
    • Dashboard Analytics
    • Tokenization
    • Crypto Checkout
      • Overview
      • Getting started
      • Checkout Dashboard
        • Creating your Store
        • Customer Checkout screens
        • Analytics
        • Managing Wallets
        • Creating Collections and NFTs
        • Linking Products to NFTs
        • Monitoring Orders
      • Checkout API
        • Authentication
        • Store
        • Orders
          • Handling Orders
    • Wallets
    • DeFi-as-a-Service
    • On & Off Ramp (soon)
    • E-commerce Plugins
      • Wordpress NFT Plugin
        • How to install NFT Plugin
        • Connect your Credentials to NFT Plugin
      • Wordpress Checkout Plugin
        • How to install Checkout Plugin
        • Connect your Credentials to Checkout Plugin
      • Plugins Guides
        • Creating your Store
        • Manage your Wallets
        • Creating Collections and NFTs
        • Linking Products to NFTs
        • Monitoring Orders
        • Monitoring Store (Analytics)
  • 💻Community Edition
    • Overview
    • Architecture
    • Start for free
    • Getting started
    • Dashboard guide
      • 🔑Creating a Project (API Key)
      • 🛠️Start building!
      • 📊Monitoring your Project
      • 📈Monitoring Requests
    • SDK guides
      • Get test currencies
      • Chainlink
        • 📈Price Feeds
        • ⚙️Automation
        • 🎲VRF
        • 🛤️CCIP
        • 🛤️CCIP
        • Project Examples
          • Lottery
          • Send Message CCIP
      • Wallets
      • Balances
      • Prices
      • Tokens
        • EVM Tokens (ERC-20)
        • Solana Tokens (SPL)
        • Cardano Tokens
        • Stellar Tokens
        • XRP Tokens
        • Hathor Tokens
      • NFTs
        • EVM NFTs (Ethereum, Polygon and others)
        • NFTs on Solana
        • NFTs on Hathor Network
      • Queries
        • Wallet information
        • Get transaction by hash
        • Get block information
        • Get transaction receipt by hash
        • Get fees information
        • Get NFT data
        • Get NFT balance
        • Get UTXOs (Unspent transaction outputs)
      • Uniswap
      • Staking
      • Smart Contracts
        • Deploy custom Smart Contracts
        • Loot Box
    • Features and credits
      • Avalanche C Chain
      • Bitcoin
      • BNB Chain
      • Cardano
      • Celo
      • Ethereum
      • Hathor
      • Polygon
      • Solana
      • Stellar
      • XRP Ledger
      • Stratus
    • API guides
      • API Cryptum
      • API Connector
  • 📃GLOSSARY
    • Blockchain terms
    • Cryptum terms
Powered by GitBook
On this page
  • What do you need a wallet for?
  • And how do you apply wallets to your business?
  • ​Integrating Wallets creation with Cryptum SDK
  1. Community Edition
  2. SDK guides

Wallets

In this guide, we'll teach you how to create a blockchain wallet for any protocol, integrated into your solution.

PreviousSend Message CCIPNextBalances

Last updated 1 year ago

Straight to the code!

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
})

What do you need a wallet for?

In a "for dummies" explanation, wallets are a prerequisite for interacting with the blockchain - whether sending values, creating NFTs, currencies or even interacting with blockchain "programs". Making a comparison with Web 2.0, it's like your login/password to perform actions.

Do not to confuse the creation of Cryptum wallets with existing wallets on the market, such as MetaMask, Phantom, TrustWallet and others. Cryptum allows the creation of the address and the private key without the need to create one of these wallets - however, you can use that same wallet created by importing the information into your preferred wallet.

And how do you apply wallets to your business?

You probably have a userbase and/or companies that will need to interact with the blockchain features, like described above.

Let's use a common example where "new users of an app need to have a wallet to receive and transfer tokens". When an approval or registration event happens in the back-end of your application, Cryptum must be called to create a wallet for this new user - 1 or N wallets. The wallet will be created, the private key will be sent to your application and the management will be done by you or your end user.

Business definitions must be created by you - Cryptum is fully prepared to generate the wallets and private keys.

As previously informed, Cryptum doesn't keep and doesn't have access to any generated Private Key. Cryptum also does not advise clients to keep end users' keys.

​Integrating Wallets creation with Cryptum SDK

Step 1

The first prerequisite you will need is the creation of an account and a Project (API Key) on Cryptum Dashboard.

Step 2

With a valid Cryptum API Key, you can then instantiate the SDK as follows:

const CryptumSdk = require('cryptum-sdk')

const sdk = new CryptumSdk({
  environment: 'testnet',  // 'testnet', 'mainnet'
  apiKey: "YOUR-API-KEY-HERE",
})

Step 3

Then you call the generateWallet() function passing the protocol you want:

const wallet = await sdk.wallet.generateWallet({ protocol: 'ETHEREUM' })

Available Protocols: BITCOIN, ETHEREUM, BSC, CELO, POLYGON, STELLAR, RIPPLE, HATHOR, CARDANO, AVAXCCHAIN, SOLANA

The function will return the newly created wallet:

Wallet {
  protocol: 'ETHEREUM',
  privateKey: '0xfb2faa54a3e9c2a285f350bbe38c4e4a630.......',
  publicKey: '0x94c778b620e0467839931e611d5ff6071952.......',
  address: '0xd09cb824b21e25370ceb930c9df7cc4e79bb6e20',
  xpub: 'xpub6DkhmSGmsjNrBSM2du8BQsGmnGjfZQDk4JAc3WD.......',
  testnet: true
}

Step 4

Wallet function can receive other parameters:

const wallet = await sdk.wallet.generateWallet({
  protocol: 'ETHEREUM',
  mnemonic: 'hurdle local pear demand practice midnight coast ...',
  derivation: { account: 0, address: 0 }  // optional
})

If you want to check the full wallet doc, go to:

To do so, access our and create a DEV-type Project.

💻
Dashboard
cryptum-sdk/wallets.md at master · blockforce-official/cryptum-sdkGitHub
Logo