# 2.4 Restore your wallet from mnemonic

If users change or loose their phone they need a way to re-enter the seed phrase and recover the wallet on a new phone.

# Use cases

Enter the 24 words of your mnemonic to re-generate the wallet.

# Tools

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

# Functions and APIs

  • Wallet derive.

# Background

From Wikipedia:

Mnemonics make use of elaborative encoding, retrieval cues, and imagery as specific tools to encode any given information in a way that allows for efficient storage and retrieval. Mnemonics aid original information in becoming associated with something more accessible or meaningful—which, in turn, provides better retention of the information.

# Step by step sequence

  1. Enter the 24 words of mnemonic;
  2. Call the wallet derive function;
  3. Finally, the result is a new wallet.

# Code Examples

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

# Dart

final mnemonicString = 'final random flame cinnamon grunt hazard easily mutual resist pond solution define knife female tongue crime atom jaguar alert library best forum lesson rigid';

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

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

# Kotlin

val mnemonicString = "final random flame cinnamon grunt hazard easily mutual resist pond solution define knife female tongue crime atom jaguar alert library best forum lesson rigid"

val mnemonic = listOf(mnemonicString)
val networkInfo = NetworkInfo(bech32Hrp = "did:com:", lcdUrl = "http://localhost:1317")

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

# C#

String mnemonicString = "final random flame cinnamon grunt hazard easily mutual resist pond solution define knife female tongue crime atom jaguar alert library best forum lesson rigid";

List<String> mnemonic = new List<String>(mnemonicString.Split(" ", StringSplitOptions.RemoveEmptyEntries));
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
9