0.0.4 • Published 2 years ago

librty-dev-kit v0.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

LDK Javascript

Documentation

Librty Dev Kit wraps up all the apis and utility codes needed to query blockchain data Install the Librty Dev Kit for Javascript through npm.

npm i librty-dev-kit

Initialize

const { LibrtyDevKit, NETWORK } = require("librty-dev-kit");

const librtyInstance = new LibrtyDevKit("api_key", NETWORK.POLYGON);

Indexer

Indexer is solely responsible for read only data and has 3 major divisions: token, nft & account. For an example if we are looking for token balance of a wallet for a particular token

const tokenBalance = librtyInstance.indexer.token.getTokenBalance("0xc2132d05d31c914a87c6611c10748aeb04b58e8f", "0x6fe489d80a48caf7472cd45f4258b9ffb5208e3c");

Under token the available functions are:

FunctionDetails
getTokenBalance(token, wallet)Get the tokens available in a wallet
getTokenInfo(token)Get token name, ticker and other info.
getNativeTokenBalance(wallet)Get native token balance of a wallet.
getTokenAllowance(token, wallet, spender)Get token allowance approved by a wallet for a spender.

token is the contract address of a particular token, wallet is the wallet address of a user and spender is the wallet address or contract address of the spender

Under nft the available functions are: | Function | Details | | ------------- | ------------- | | getNFTDetails(token, tokenId) | Get detail of a particular NFT | | getCollectionInfo(token) | Get detail of a collection |

token is the contract address of a NFT contract and tokenId is the id of the particular nft token.

Under account the available functions are:

FunctionDetails
getTransactionDetails(hash)Get transaction details of a given hash

hash is the unique transaction hash of a particular transaction.

Simulation

We understand working with blockchain is new and interacting with it is time consuming as well, we introduce an option to simulate the response of apis, this will help developers seamlessly integrate the SDK.

const { LibrtyDevKit, NETWORK, LDKResponseMapper } = require("librty-dev-kit");

const responseMapper = new LDKResponseMapper();
responseMapper.setTokenBalance({
    "status": 1,
    "message": "SUCCESS",
    "data": "47099"
});
const librtyInstance = new LibrtyDevKit("api_key", NETWORK.SIMULATION, responseMapper);

const tokenBalance = librtyInstance.indexer.token.getTokenBalance("0xc2132d05d31c914a87c6611c10748aeb04b58e8f", "0x6fe489d80a48caf7472cd45f4258b9ffb5208e3c");
0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago