Skip to main content

Wallets

info

A wallet is used to create and sign transactions. It will have a unique address, and be generated from a seed phrase. The nodes will perform validations of the signature and the wallet's existence in the blockchain for those transactions, so it's a requirement to use valid wallets when creating transactions. See Register a wallet with a blockchain for validating a wallet with one of a node's blockchains.

File Wallets

A file wallet is a wallet that can be saved and loaded from disk.

Create a wallet

To create a wallet on the local file system you will follow these steps:

#include "ULC.hpp"

#include <iostream>

using namespace ULC::Wallet;

UL_FileWallet wallet{};
wallet.SetWalletFilePath("local path to the wallet file"); // This is either where the wallet lives, or where it will be created at.
wallet.GenerateSeedPhrase("local path to a words list file"); // The file is expected to be one of the following valid bip39 words lists: https://www.blockplate.com/pages/bip-39-wordlist
bool success = wallet.GenerateFromSeedPhrase();
if (!success) {
// Handle error.
}

// Print the wallet as formatted json.
std::cout << wallet.ToJson(true).c_str() << std::endl;

wallet.Save();
info

Your seed phrase is important to keep safe. Do not lose it. It's the users responsibility to keep their seed phrase secure. If it is lost there is nothing we can do to recover it.

It's always a good idea to keep a secure offline copy of your seed phrase. You can always recover your wallet using the seed phrase.

More on seed phrases and BIP39:

Seed Phrase | BIP39

Save Encrypted Wallet

To save a wallet as an encrypted file, do the following:

// Wallet was created
wallet.Save(true, "MyOptionalPassword");

Load an Encrypted/Unencrypted Wallet File

info

A wallet files format is in json.

To load a wallet from an unencrypted file, do the following:

#include "ULC.hpp"

#include <iostream>

using namespace ULC::Wallet;

UL_FileWallet wallet{};
wallet.SetWalletFilePath("local path to the wallet file"); // The location of the wallet file.
bool success = wallet.Load(); // Load the wallet without decryption.
if (!success) {
// Handle error
}

To load a wallet from an encrypted file, do the following:

#include "ULC.hpp"

#include <iostream>

using namespace ULC::Wallet;

UL_FileWallet wallet{};
wallet.SetWalletFilePath("local path to the wallet file"); // The location of the wallet file.
bool success = wallet.Load(true, "Wallet Password");
if (!success) {
// Handle error
}

To register a wallet with a blockchain on a node see: Register a wallet with a blockchain


Previous Step

Connect to the BMS

Next Steps

Interacting with a node

Back to Getting Started

Getting Started

© 2023 ULedger Inc. All rights reserved