Module wallets

Source
Expand description

§Neo Wallets

Wallet management for the Neo N3 blockchain.

§Overview

The neo_wallets module provides comprehensive wallet management functionality for the Neo N3 blockchain. It includes:

  • Wallet creation and loading
  • NEP-6 wallet standard support
  • BIP-39 mnemonic phrase support
  • Transaction signing
  • Key management and derivation
  • Hardware wallet integration (Ledger)
  • Secure key storage
  • Wallet backup and recovery

This module enables secure management of private keys and accounts, allowing users to interact with the Neo N3 blockchain in a secure manner.

§Examples

§Creating and using a wallet

use neo3::neo_wallets::Wallet;
use std::path::PathBuf;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a new wallet
    let mut wallet = Wallet::new();
     
    // Create a new account in the wallet
    let account = wallet.create_new_account()?;
    println!("New account address: {}", account.get_address());
     
    // Save the wallet to a file
    wallet.save_to_file(PathBuf::from("my_wallet.json"))?;
     
    Ok(())
}

§Working with BIP-39 accounts

use neo3::neo_wallets::Bip39Account;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a new BIP-39 account
    let account = Bip39Account::create("password123")?;
    println!("Generated mnemonic: {}", account.mnemonic());
     
    // Recover an account from a mnemonic
    let mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art";
    let recovered = Bip39Account::from_bip39_mnemonic("password123", mnemonic)?;
     
    Ok(())
}

Structs§

Bip39Account
A BIP-39 compatible neo account that uses mnemonic phrases for key generation and recovery.
LedgerWallet
A Ledger hardware wallet signer for Neo N3.
NEP6Account
Represents an account in the NEP-6 format.
NEP6Contract
Represents a NEP-6 contract.
NEP6Parameter
Represents a NEP-6 parameter.
Nep6Wallet
Represents a NEP-6 wallet.
Wallet
WalletBackup
Provides functionality for backing up and recovering Neo wallets.
WalletSigner
A Neo private-public key pair which can be used for signing messages.

Enums§

HDPath
Represents a hierarchical deterministic path for Neo N3 accounts.
SignerError
Represents errors that can occur within the signing process.
WalletError
Errors that may occur within wallet operations.

Traits§

WalletTrait
Represents the core functionalities of a cryptocurrency wallet.

Type Aliases§

LocalWallet
A wallet instantiated with a locally stored private key
YubiWallet
A wallet instantiated with a YubiHSM