# Wallet

- [Wallet](#wallet)
  - [Introduction](#introduction)
  - [Usage with JavaScript SDK](#usage-with-javascript-sdk)
    - [Properties](#properties)
      - [Seed](#seed)
    - [Actions](#actions)
      - [Register a new Wallet](#register-a-new-wallet)
      - [Instantiate from an Existing Seed](#instantiate-from-an-existing-seed)
      - [Get Account Object for a Certain Nonce](#get-account-object-for-a-certain-nonce)

## 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 JavaScript SDK

In JavaScript SDK we have a `Wallet` class that represents a wallet on the VSYS blockchain.

### Properties

#### Seed

The seed of the wallet.

```javascript
// wal: Wallet

console.log(wal.seed);
```

Example output

```
Seed {
  data: 'chair library xxxx xxxx master pause west ladder valley survey behave attend culture clip blush'
}
```

### Actions

#### Register a new Wallet

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

```javascript
wal = Wallet.register();
console.log(wal);
```

Example output

```
Wallet {
  seed: Seed {
    data: 'glove safe safe collect switch winter jacket skill slender banner gift industry time skin suit'
  }
}
```

#### Instantiate from an Existing Seed

Instantiate `Wallet` from an existing seed.

```javascript
const host = 'http://veldidina.vos.systems:9928';
const api = NodeAPI.new(host);
const ch = new Chain(api, ChainID.TEST_NET);
const seed = new md.Seed(
  'chair library crew inject master pause west ladder valley survey behave attend culture clip blush'
);
const wal = new Wallet(seed);
const acnt0 = wal.getAcnt(ch, 0);
console.log(acnt0.addr.data);
```

Example output

```
AU7Bekp3fBj25vPR6w1PK7cDC8kDJoLTiCQ
```

#### Get Account Object for a Certain Nonce

Get the `Account` object for a certain nonce.

```javascript
// ch: Chain

const wal = Wallet.register();
const acnt0 = wal.getAcnt(ch, 0);
console.log(acnt0.addr);
```

Example output

```
Addr { data: 'AU7Bekp3fBj25vPR6w1PK7cDC8kDJoLTiCQ' }
```
