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
NPM
npm install @lunarhq/rosetta-ts-client
Yarn
yarn add @lunarhq/rosetta-ts-client
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)
You can read more about the Rosetta Data API endpoints at rosetta-api.org/docs/data_api_introduction.html
networksList(req: MetadataRequest): Promise<NetworkListResponse>
networkOptions(req: NetworkRequest): Promise<NetworkOptionsResponse>
networkOptions(req: NetworkRequest): Promise<NetworkOptionsResponse>
accountBalance(req: AccountBalanceRequest): Promise<AccountBalanceResponse>
accountCoins(req: AccountCoinsRequest): Promise<AccountCoinsResponse>
block(req: BlockRequest): Promise<BlockResponse>
blockTransaction(req: BlockTransactionRequest): Promise<BlockTransactionResponse>
mempool(req: NetworkRequest): Promise<MempoolResponse>
mempoolTransaction(req: MempoolTransactionRequest): Promise<MempoolTransactionResponse>
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(req: ConstructionCombineRequest): Promise<ConstructionCombineResponse>
derive(req: ConstructionDeriveRequest): Promise<ConstructionDeriveResponse>
hash(req: ConstructionHashRequest): Promise<TransactionIdentifierResponse>
metadata(req: rosetta.ConstructionMetadataRequest): Promise<rosetta.ConstructionMetadataResponse>
parse(req: rosetta.ConstructionParseRequest): Promise<rosetta.ConstructionParseResponse>
payloads(req: rosetta.ConstructionPayloadsRequest): Promise<rosetta.ConstructionPayloadsResponse>
preprocess(req: rosetta.ConstructionPreprocessRequest): Promise<rosetta.ConstructionPreprocessResponse>
submit(req: rosetta.ConstructionSubmitRequest): Promise<rosetta.TransactionIdentifierResponse>