---
# System prepended metadata

title: Client Libs Deep Dive

---

# Client Libs Deep Dive


## wallet.rs - nodejs binding examples
https://github.com/iotaledger/wallet.rs/tree/develop/wallet/bindings/nodejs

### 1-create-account.js

Current Example: 
https://github.com/iotaledger/wallet.rs/blob/develop/wallet/bindings/nodejs/examples/1-create-account.js

Proposal:
```javascript
/**
 * This example creates a new database and account
 */

require('dotenv').config({ path: '../.env' });
const { AccountManager } = require('@iota/wallet');
// this should be moved to the wallet lib
const { createAccountManager } = require('./helper');

async function run() {
    try {

        // createAccountManager(mnemonic, password, options?)
        const manager = new AccountManager(process.env.MNEMONIC, process.env.SH_PASSWORD);
        
        // or without mnemonic
        // createAccountManager(password, options?)
        // const manager = new AccountManager(process.env.SH_PASSWORD);
        // await manager.storeMnemonic(process.env.MNEMONIC);
        
        const account = await manager.createAccount('Alice');
        console.log('Account created:', account);

        const secondAccount = await manager.createAccount('Bob');
        console.log('Account created:', secondAccount);
    } catch (error) {
        console.log('Error: ', error);
    }
    process.exit(0);
}

run();

```

### 4a-send-amount.js


Current Example: https://github.com/iotaledger/wallet.rs/blob/develop/wallet/bindings/nodejs/examples/4a-send-amount.js


Proposal:
```javascript
/**
 * This example sends a specified amount to an address.
 */

const getUnlockedManager = require('./account-manager');

async function run() {
    try {
        const manager = await getUnlockedManager(); // Can we also move this to lib somehow?
        const account = await manager.getAccount('Alice');
        console.log('Account:', account);

        await account.sync(); // <- getAccount could always return a syced account.

        //TODO: Replace with the address of your choice!
        const address =
            'rms1qrrv7flg6lz5cssvzv2lsdt8c673khad060l4quev6q09tkm9mgtupgf0h0';
        const amount = '1000000';

        const response = await account.sendAmount(address, amount);
        // shorter -> await account.send(address, amount);
        // Like ERC20 -> await account.transfer(address, amount);

        console.log(response);

        console.log(
            `Check your block on http://localhost:14265/api/core/v2/blocks/${response.blockId}`,
        );
    } catch (error) {
        console.log('Error: ', error);
    }
    process.exit(0);
}

run();

```

### 22-mint-native-tokens.js

Current Example: https://github.com/iotaledger/wallet.rs/blob/develop/wallet/bindings/nodejs/examples/22-mint-native-tokens.js

Proposal:
```javascript

/**
 * This example mints native tokens
 */
const getUnlockedManager = require('./account-manager');

async function run() {
    try {
        const manager = await getUnlockedManager(); // Can we also move this to lib somehow?

        const account = await manager.getAccount('Alice');

        await account.sync(); // <- getAccount could always return a syced account.

        
        // Add TIP30 into the lib, so every token is standard conform. 
        // https://iotaledger.github.io/tips/tips/TIP-0030/tip-0030.html
        let nativeTokenOptions = {
            name: "My Token",
            symbol: "MTK",
            maximumSupply: 1000
        }

        let nativeToken = new TokenClient(nativeTokenOptions)

        let { transaction } = await account.mintNativeToken(nativeToken, 100);

        // OR like in ERC20
        // let { transaction } = await nativeToken.mint(account, 100);

        
        console.log('Transaction ID: ', transaction.transactionId);
    } catch (error) {
        console.log('Error: ', error);
    }
    process.exit(0);
}

run();

```

### 24-send-native-tokens.js

Current Example: 
https://github.com/iotaledger/wallet.rs/blob/develop/wallet/bindings/nodejs/examples/24-send-native-tokens.js

Proposal:
```javascript
/**
 * This example will send native tokens
 */
const getUnlockedManager = require('./account-manager');

async function run() {
    try {
        const manager = await getUnlockedManager();

        const account = await manager.getAccount('Alice');

        await account.sync();

        //TODO: Replace with the address of your choice!
        let address =
            'rms1qrrv7flg6lz5cssvzv2lsdt8c673khad060l4quev6q09tkm9mgtupgf0h0';

        // TODO: Get a tokenId from your account balance after running example
        // 22-mint-native-tokens.js
        let tokenId =
            '0x087ec7c0a543e60cfc92850ed053d3b323c0d7181e63b24c6ef24dd591814006950100000000';

        // New client to handle everything with tokens (inspired by ERC20)
        let token = new TokenClient(tokenId);

        token.totalSupply();
        // Output => 1000

        token.balanceOf(account.address);
        // Output => 100

        token.balanceOf(address);
        // Output => 0

        const response = await account.sendNativeTokens(token, address, 10);
        
        // OR like ERC20
        // token.transfer(from: account, to: address, value: 10);
        // const response = await token.transfer(account, address, 10);

        console.log(response);

        console.log(
            `Check your block on http://localhost:14265/api/core/v2/blocks/${response.blockId}`,
        );

        token.balanceOf(account.address);
        // Output => 90

        token.balanceOf(address);
        // Output => 10

    } catch (error) {
        console.log('Error: ', error);
    }
    process.exit(0);
}

run();

```