Code Monkey home page Code Monkey logo

rosetta-ts-client's Introduction

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>

rosetta-ts-client's People

Contributors

rhyslbw avatar stuartwk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

rhyslbw

rosetta-ts-client's Issues

Make RosettaClientParams.baseUrl required

I'll be sure to check this library out in more depth, but my cursory review surfaced a minor but important issue regarding adoption. The fallback to a specific server might be a nice convenience for Lunar clients, but it's a boundary violation, and would be confusing for other implementations. I'd suggest just requiring the value passed in explicitly, and would be happy to open a PR if you agree.

Thanks for the work so far!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.