Skip to content

NPM module that provides helper functions for working with the Stellar blockchain.

Notifications You must be signed in to change notification settings

Spxc/Stellar-blockchain-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stellar Blockchain Helper

This is an npm module that provides helper functions for working with the Stellar blockchain.


Installation

To use this module, you need to have Node.js installed. Then, you can install the module using npm:

npm install stellar-blockchain-helper

Usage

First, require the module in your code:

const { loadAccountPools, loadPoolDetails } = require('stellar-blockchain-helper');

loadAccountPools(account)

This function loads the liquidity pool balances for a given Stellar wallet address.

Parameters

  • account (type: String): Stellar wallet address.

Returns

  • Promise: A promise that resolves to an array of liquidity pool balances.

loadPoolDetails(balance)

This function loads the details of a liquidity pool.

Parameters

  • balance (type: JSON Object): Account balance object.

Returns

  • Promise: A promise that resolves to a JSON object containing the pool details.

Examples

Fetch account pool balances

const account = 'GA5GP75JXAMWQZWQI56X46EGYSCTQEG7AC2FB6UGMLCZNBQV3LNE4EKX';

loadAccountPools(account)
  .then(pools => {
    if (pools) {
      console.log('Liquidity Pools:', pools);
    } else {
      console.log('No liquidity pools found.');
    }
  })
  .catch(error => {
    console.error('Error:', error);
  });

Fetch & convert account shares into tokens based off the liquidity pool

const poolObject = {
  liquidity_pool_id: '1234567890',
  balance: 1000
};

loadPoolDetails(poolObject)
  .then(pool => {
    if (pool) {
      console.log('Pool Details:', pool);
    } else {
      console.log('Failed to load pool details.');
    }
  })
  .catch(error => {
    console.error('Error:', error);
});

Dependencies

  • Stellar SDK (to communicate with the stellar network)
  • dotenv (load local .env files)
  • jest (for running unit testing)

License

This module is licensed under the MIT License. See the LICENSE file for details.

About

NPM module that provides helper functions for working with the Stellar blockchain.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published