# 2.2 Generate an HD Wallet

Everything starts here. The seed phrase is a list of words which store all the information needed to generate o recover your account. HD stands for hierarchical deterministic. A deterministic wallet is a system of deriving keys from a single starting point known as a seed. The seed allows a user to easily back up and restore a wallet without needing any other information and can allow the creation of public addresses without the knowledge of the private key.

Seed phrase are serialized into 24 human-readable words in a Seed phrase. This 24 words are created by using the bip39 standard.

The BIP39 describes the implementation of a mnemonic sentence -- a group of easy to remember words -- for the generation of deterministic wallets.

It consists of two parts: generating the mnemonic, and converting it into a binary seed.

A mnemonic code or sentence is superior for human interaction compared to the handling of raw binary or hexadecimal representations of a wallet seed. The sentence can be written on paper or spoken over the telephone.

# Use cases

You must create a wallet before doing anything with the tools offered by Commercio.network SDK.

In our case the wallet will be used to sign, with the keys contained in it, the transactions that will then be sended to the Commercio.network blockchain.

# Tools

The Sacco library, our own open source tool to sign and send transactions to any Cosmos SDK based blockchain, including Commercio.network.

The Bitcoin BIP39 Mnemonic code for generating deterministic keys.

# Functions and APIs

  • Wallet derive.

# Background

From Wikipedia:

A cryptocurrency wallet is a device, physical medium, program or a service which stores the public and private keys and can be used to track ownership, receive or spend cryptocurrencies.

# Step by step sequence

  1. Generate a new mnemonic using bip39;
  2. Set up the network;
  3. Call the wallet derive function;
  4. Finally, the result is a new wallet.

# Code Examples

Here's an example of the implementation in all the available languages.

# Dart

final mnemonic = bip39.generateMnemonic(strength: 256).split(' ');
final networkInfo = NetworkInfo(
  bech32Hrp: 'did:com:',
  lcdUrl: 'http://localhost:1317',
);

final wallet = Wallet.derive(mnemonic, networkInfo);
1
2
3
4
5
6
7

# Kotlin

val mnemonic = generateMnemonic(strength = 256, wordList = WORDLIST_ENGLISH).split(" ")
val networkInfo = NetworkInfo(bech32Hrp = "did:com:", lcdUrl = "http://localhost:1317")

val wallet = Wallet.derive(mnemonic = mnemonic, networkInfo = networkInfo)
1
2
3
4

# C#

var mnemonicWords = new dotnetstandard_bip39.BIP39().GenerateMnemonic(strength: 256, wordlistType: dotnetstandard_bip39.BIP39Wordlist.English);
var mnemonic = new List<string>(mnemonicWords.Split(" "));
static commercio.sacco.lib.NetworkInfo networkInfo = new commercio.sacco.lib.NetworkInfo(
                bech32Hrp: "did:com:",
                lcdUrl: "http://localhost:1317"
              );

var wallet = commercio.sacco.lib.Wallet.derive(mnemonic, networkInfo);
1
2
3
4
5
6
7
8