Skip to content

lunarhq/rosetta-ts-client

Repository files navigation

Rosetta TypeScript Client

This package is for making queries to a Rosetta Node or a Rosetta-compliant service. Read more about Rosetta at rosetta-api.org

All testnet calls are free. To increase your rate limit or make mainnet queries, get a key at lunar.dev.

All endpoints are Rosetta compliant. Read more about Rosetta at rosetta-api.org

Installation

NPM

npm install @lunarhq/rosetta-ts-client

Yarn

yarn add @lunarhq/rosetta-ts-client

Usage

Create a new client. Both baseUrl and headers are optional. If no baseUrl is provided, the client will default to lunar.dev.

import { RosettaClient } from '@lunarhq/rosetta-ts-client';

/**
 * Initialize Client
 */ 
const baseUrl = 'https://api.lunar.dev/v1';
const headers = {
  'X-Api-Key': 'XXXXXXXXXX'
}
const client = new RosettaClient({baseUrl, headers});

/**
 * Get list of available networks
 */ 
const metadata = {}
const networks = await client.networksList(metadata)

Data Endpoints

You can read more about the Rosetta Data API endpoints at rosetta-api.org/docs/data_api_introduction.html

Network List

networksList(req: MetadataRequest): Promise<NetworkListResponse>

Network Options

networkOptions(req: NetworkRequest): Promise<NetworkOptionsResponse>

Network Status

networkOptions(req: NetworkRequest): Promise<NetworkOptionsResponse>

Account Balance

accountBalance(req: AccountBalanceRequest): Promise<AccountBalanceResponse>

Account Coins

accountCoins(req: AccountCoinsRequest): Promise<AccountCoinsResponse>

Block

block(req: BlockRequest): Promise<BlockResponse>

Block Transaction

blockTransaction(req: BlockTransactionRequest): Promise<BlockTransactionResponse>

Mempool

mempool(req: NetworkRequest): Promise<MempoolResponse>

Mempool Transaction

mempoolTransaction(req: MempoolTransactionRequest): Promise<MempoolTransactionResponse>

Construction Endpoints

Construction endpoints are used to write to a blockchain. You can read more about the Rosetta Construction API endpoints at rosetta-api.org/docs/construction_api_introduction.html

Combine

combine(req: ConstructionCombineRequest): Promise<ConstructionCombineResponse>

Derive

derive(req: ConstructionDeriveRequest): Promise<ConstructionDeriveResponse>

Hash

hash(req: ConstructionHashRequest): Promise<TransactionIdentifierResponse>

Metadata

metadata(req: rosetta.ConstructionMetadataRequest): Promise<rosetta.ConstructionMetadataResponse>

Parse

parse(req: rosetta.ConstructionParseRequest): Promise<rosetta.ConstructionParseResponse>

Payloads

payloads(req: rosetta.ConstructionPayloadsRequest): Promise<rosetta.ConstructionPayloadsResponse>

Preprocess

preprocess(req: rosetta.ConstructionPreprocessRequest): Promise<rosetta.ConstructionPreprocessResponse>

Submit

submit(req: rosetta.ConstructionSubmitRequest): Promise<rosetta.TransactionIdentifierResponse>