<commit_before># [ChainOrchestra-SDK](https://github.com/ChainOrchestra/ChainOrchestra-SDK)

## Value [exchange](http://chainorchestra.net/#/5) example

### General design

The value [exchange](http://chainorchestra.net/#/5) live demo page is on [chainorchestra.net](http://chainorchestra.net).

### Sample session

```
cd examples/exchange/js/
./accountList.js 
./deskOperation.js open "<NAME>"
./tellerOperation.js deposit "<NAME>" 100
./accountStatus.js "<NAME>"
./deskOperation.js open "<NAME>"
./transferOperation.js "<NAME>" "<NAME>" 10
./accountStatus.js "<NAME>"
./tellerOperation.js withdrawal "<NAME>" 90
./tellerOperation.js withdrawal "<NAME>" 10
./deskOperation.js close "<NAME>"<commit_msg>Exchange example general design<commit_after># [ChainOrchestra-SDK](https://github.com/ChainOrchestra/ChainOrchestra-SDK)

## Value [exchange](http://chainorchestra.net/#/5) example

### General design

This sample digital currency application opens accounts, manages deposits, withdrawals and transfers.
The balance needs to be 0 before closing an account.

In the blockchain DB, the account name is the key and the value is the account balance.

The value [exchange](http://chainorchestra.net/#/5) live demo page is on [chainorchestra.net](http://chainorchestra.net).

#### Desk operations

Blockchain users with [BankClerk permissions](../../lib/chaincode/perms) manage the open / close operations.

```
---- ---- ---- ---- ---- ----+---- ---- ---- ----+---- ---- ---- ---- ---- ---- 
     Initial balance         |      Operation    |         Next balance
---- ---- ---- ---- ---- ----+---- ---- ---- ----+---- ---- ---- ---- ---- ---- 
                             |                   |
     <undefined>             |        open       |             0
                             |                   |
          0                  |       close       |         <undefined> 
                             |                   |
---- ---- ---- ---- ---- ----+---- ---- ---- ----+---- ---- ---- ---- ---- ---- 
 
```

#### Teller operations

Blockchain users with [Cashier permissions](../../lib/chaincode/perms) manage the deposit / withdrawal / transfer operations.

```
---- ---- ---- ---- ---- ----+---- ---- ---- ----+---- ---- ---- ---- ---- ---- 
     Initial balance         |      Operation    |         Next balance
---- ---- ---- ---- ---- ----+---- ---- ---- ----+---- ---- ---- ---- ---- ---- 
                             |                   |
           N                 |     deposit x     |          N + x
                             |                   |
           N                 |    withdrawal x   |          N - x
                             |                   |
   fromAccount: N            |     transfer x    |          N - x
    toAccount: M             |                   |          M + x
                             |                   |
---- ---- ---- ---- ---- ----+---- ---- ---- ----+---- ---- ---- ---- ---- ---- 
 
```


### Sample session

```
cd examples/exchange/js/
./accountList.js 
./deskOperation.js open "<NAME>"
./tellerOperation.js deposit "<NAME>" 100
./accountStatus.js "<NAME>"
./deskOperation.js open "<NAME>"
./transferOperation.js "<NAME>" "<NAME>" 10
./accountStatus.js "<NAME>"
./tellerOperation.js withdrawal "<NAME>" 90
./tellerOperation.js withdrawal "<NAME>" 10
./deskOperation.js close "<NAME>"
{'fraction_non_alphanumeric': 0.22436849925705796, 'fraction_numerical': 0.007429420505200594, 'mean_word_length': 1.2101116217990808, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6315153', 'n_tokens_mistral': 975, 'n_tokens_neox': 854, 'n_words': 202}