Skip to content

raoulpicconi/mintlayer-rpc-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mintlayer RPC Client

npm version License: MIT

A type-safe JavaScript/TypeScript client for interacting with a Mintlayer node via RPC.

Installation

npm install mintlayer-rpc-client

or

yarn add mintlayer-rpc-client

Usage

import { MintlayerRpcClient } from 'mintlayer-rpc-client';

// Create a client
const client = new MintlayerRpcClient({
    url: 'http://127.0.0.1:8000',
    auth: {
        username: 'user',
        password: 'password'
    }
});

// Usage examples
async function example() {
    try {
        // Get wallet info
        const walletInfo = await client.walletInfo();
        console.log('Wallet info:', walletInfo);

        // Create a new account
        const newAccount = await client.accountCreate({ name: 'My Account' });
        console.log('New account:', newAccount);

        // Generate a new address
        const newAddress = await client.addressNew({ account: 0 });
        console.log('New address:', newAddress);

        // Check balance
        const balance = await client.accountBalance({
            account: 0,
            utxo_states: ['Confirmed'],
            with_locked: 'Unlocked'
        });
        console.log('Balance:', balance);

        // Send coins
        const txResult = await client.addressSend({
            account: 0,
            address: 'ml1qt72v5anu3gd04vn7r8djv0hfjz9vq9x9w3arjr4gy703mmg9zvfq8gmc5r',
            amount: { decimal: '1.0' },
            options: { in_top_x_mb: 5 }
        });
        console.log('Transaction sent:', txResult);
    } catch (error) {
        console.error('Error:', error);
    }
}

example();

API Documentation

The client provides type-safe methods for all Mintlayer RPC endpoints. Each method corresponds to an RPC method in the Mintlayer node.

Wallet Methods

  • walletCreate(params) - Create a new wallet
  • walletOpen(params) - Open an existing wallet
  • walletClose() - Close the currently open wallet
  • `walletInfo()

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors