Skip to content

Latest commit

 

History

History
95 lines (70 loc) · 2.32 KB

wallet.md

File metadata and controls

95 lines (70 loc) · 2.32 KB

Wallet

Introduction

Wallet can be thought of as a group of user accounts. Each wallet has its own seed. A private key that represents an account can be generated by hashing the seed and a nonce.

Usage with Go SDK

In Go SDK we have a Wallet struct that represents a wallet on the VSYS blockchain.

Properties

Seed

The seed of the wallet.

// wal: *vsys.Wallet

fmt.Println(wal.Seed)

Example output

*vsys.Seed(vsys.Str(choose icon security demise fashion robot file dune green play social define clump hedgehog issue))

Actions

Register a new Wallet

Register a new wallet(i.e. generate a new seed)

wal, err := vsys.GenWallet()
if err != nil {
    log.Fatalln(err)
}
fmt.Println(wal)

Example output

*vsys.Wallet({Seed:*vsys.Seed(vsys.Str(pony shield detail govern emotion present regular still else jar shrug speed destroy plug project))})

Instantiate from an Existing Seed

Instantiate Wallet from an existing seed.

seed_str := "choose icon security demise fashion robot file dune green play social define clump hedgehog issue"

wal, err := vsys.NewWalletFromSeedStr(seed_str)
fmt.Println(wal.seed)

// OR

seed, err := vsys.NewSeed(SEED)
wal := vsys.NewWallet(seed)
fmt.Println(wal.seed)

Example output

*vsys.Seed(vsys.Str(choose icon security demise fashion robot file dune green play social define clump hedgehog issue))
*vsys.Seed(vsys.Str(choose icon security demise fashion robot file dune green play social define clump hedgehog issue))

Get Account Object for a Certain Nonce

Get the Account object for a certain nonce.

// ch: *vsys.Chain
// wal: *vsys.Wallet

acnt0, err := wal.GetAccount(ch, 0)
print(acnt0.Addr)
acnt1, err := wal.GetAccount(ch, 1)
print(acnt1.Addr)

Example output

*vsys.Addr(vsys.Str(ATraTqyhkHfbMAJawsyZeikkgS3nxy2iM5A))
*vsys.Addr(vsys.Str(AUCkJmLvAYsHjS9vV9NZ32XJ5BBYGPvvatJ))