@openworklabs/lotus-block-explorer

0.1.4 • Public • Published

⚠️ Active development. Unstable. Breaking Changes. You get the point.

A javascript module for exploring lotus running locally on your machine. See the Lotus docs for more information.

npm i @openworklabs/lotus-block-explorer

Basic exploration

const lotus = new Lotus({ token: '<your-jwt-token>' })

const chainUpdateCallback = chainState => {
  // will log the updated chain state any time new blocks are explored
  console.log(chainState)
}

// subscribe to chain updates
lotus.store.subscribe(chainUpdateCallback)

// start exploring Lotus heights
await lotus.explore({ toHeight: 'latest', fromHeight: '0' })

// get the current chain state
const currentChainState = lotus.store.getState()

// when you're done, stop listening for updates
lotus.store.unsubscribe(chainUpdateCallback)

Chain Listening

const lotus = new Lotus({ token: '<your-jwt-token>' })

const chainUpdateCallback = chainState => {
  // will log the updated chain state any time new blocks are explored
  console.log(chainState)
}

// subscribe to chain updates
lotus.store.subscribe(chainUpdateCallback)

// poll lotus for new tipsets to add to the in-memory chain store
lotus.listen()

// cancel listeners
lotus.stopListening()
lotus.store.unsubscribe(chainUpdateCallback)

Constructor options

{
  jsonrpcEndpoint: <String> (defaults to 'http://127.0.0.1:1234/rpc/v0')
  token: <String> (jwt token see [here](https://docs.lotu.sh/en+api-scripting-support))
}

explore options

await lotus.explore({
  fromHeight: (<String> || <Number>),
  toHeight: (<String> || <Number>) // defaults to the current ChainHead
})

CORS

If you're running this package in a Create React App, for development purposes you can proxy api requests. More info. When it comes to production or other browser use cases, you will need to set Lotus behind a proxy like NGNIX. Here is a sample docker container: https://github.com/RTradeLtd/lotus-infra

Readme

Keywords

none

Package Sidebar

Install

npm i @openworklabs/lotus-block-explorer

Weekly Downloads

11

Version

0.1.4

License

(Apache-2.0 OR MIT)

Unpacked Size

132 kB

Total Files

14

Last publish

Collaborators

  • thomasbeta
  • schwartzz8990