Skip to content

SingleAddressWallet

Extends: RefCounted

Description

This class holds the [b]encrypted[/b] master private key of a user's wallet. It can be used for offline wallet operations and queries, such as signing, adding accounts and consulting addresses. You should create a SingleAddressWallet with [SingleAddressWalletLoader], by calling any of its creation or import methods. Refer to [OnlineWallet] for a class that has network connectivity and can do blockchain queries. In general, this class is the one you are interested in for dApp development.

This class holds the [b]encrypted[/b] master private key of a user's wallet. It can be used for offline wallet operations and queries, such as signing, adding accounts and consulting addresses. You should create a SingleAddressWallet with [SingleAddressWalletLoader], by calling any of its creation or import methods. Refer to [OnlineWallet] for a class that has network connectivity and can do blockchain queries. In general, this class is the one you are interested in for dApp development.

Constants Descriptions

Status

enum Status{SUCCESS = 0, DECRYPTION_ERROR = 1, BAD_DECRYPTED_KEY = 2, BECH32_ERROR = 3, NON_EXISTENT_ACCOUNT = 4}

Method Descriptions

_init

func _init(wallet: _SingleAddressWallet, wallet_loader: SingleAddressWalletLoader) -> SingleAddressWallet

WARNING: Do not use this constructor! Use any of the import/creation methods exposed in [SingleAddressWalletLoader].

get_address

func get_address() -> Address

Get the account's Address

get_address_bech32

func get_address_bech32() -> String

Get the account's address as a BECH32-encoded [String].

get_address_hex

func get_address_hex() -> String

sign_transaction

func sign_transaction(password: String, tx: Transaction) -> SignTxResult

Sign the given Transaction

sign_data

func sign_data(password: String, data: String) -> SignDataResult

Sign the given [String] representing hex encoded payload and obtain a [DataSignature]

add_account

func add_account(account_index: int, password: String) -> AddAccountResult

Adds an account to this wallet with the given index

switch_account

func switch_account(account: Account) -> int

Switch to the account with the given account_index. It may fail if no such account exists. It returns the account index when it succeeds.

accounts

func accounts() -> Array[Account]

Return a list of accounts currently available in the wallet

export

func export() -> SingleAddressWalletResource

Export wallet to a resource.

Sub-classes

SignDataResult

Property Descriptions

value

var value: DataSignature
  • Getter: @value_getter

WARNING: This function may fail! First match on Result.tag or call Result.is_ok.

error

var error: String
  • Getter: @error_getter

WARNING: This function may fail! First match on Result.tag or call Result._is_err.

AddAccountResult

Property Descriptions

value

var value: Account
  • Getter: @value_getter

WARNING: This function may fail! First match on Result.tag or call Result.is_ok.

error

var error: String
  • Getter: @error_getter

WARNING: This function may fail! First match on Result.tag or call Result._is_err.