npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cityofzion/neo-js

v0.14.0

Published

Running NEO blockchain full node with Node.js and MongoDB.

Downloads

437

Readme

Overview

neo-js package is designed to interface with the NEO blockchain in a number of different ways that are configured by options that are used to initialize a node. A few examples of these different interaction mechanics are defined in the quickstart below as well as in the examples.

This is not a SDK library for interacting with NEO blockchain. You are looking for neon-js.

Getting Started

Preparations

Currently this module only support MongoDB for synchronizing the blockchain. You are expect to be connected to an instance of MongoDB 3.2+ to use most of its features.

System Recommendations

  • NodeJS 8+
  • MongoDB 3.2+

Installation

Install the package using:

$ npm install --save @cityofzion/neo-js

Alternatively, to access to the latest available code, you can reference to the git repository directly:

$ npm install --save git://github.com/CityOfZion/neo-js.git#develop

Quick Start

More comprehensive examples can be found at neo-js-examples repository.

const Neo = require('@cityofzion/neo-js').Neo

To create a new blockchain instance:

// Create a neo instances to interface with RPC methods
const testnetNeo = new Neo({ network: 'testnet' })

// Wait for mesh to be ready before attempt to fetch block information
testnetNeo.mesh.on('ready', () => {
  testnetNeo.api.getBlockCount()
    .then((res) => {
      console.log('Testnet getBlockCount:', res)
    })
})

// To connect to the mainnet:
const mainnetNeo = new Neo({ network: 'mainnet' })

mainnetNeo.mesh.on('ready', () => {
  mainnetNeo.api.getBlock(1000)
    .then((res) => {
      console.log('Mainnet getBlock(1000).hash:', res.hash)
    })
})

This will create a new node instance and configure it to sync the blockchain to the defined mongoDB collections:

const options = {
  network: 'testnet',
  storageType: 'mongodb',
  storageOptions: {
    connectionString: 'mongodb://localhost/neo_testnet',
  },
}

// Create a neo instance
const neo = new Neo(options)

// Get block height
neo.storage.on('ready', () => {
  neo.storage.getHighestBlockHeight()
    .then((res) => {
      console.log('Block height:', res)
    })
})

Documentation

Documentation for the project can be found at:

You can find more code examples at repository:

Blockchain Bootstrap Files

Please refer to Bootstrap Files document

Options

Please refer to Optional Parameters document

Events

Please refer to Event Emitters document

Contribution

neo-js always encourages community code contribution. Before contributing please read the contributor guidelines and search the issue tracker as your issue may have already been discussed or fixed. To contribute, fork neo-js, commit your changes and submit a pull request.

By contributing to neo-js, you agree that your contributions will be licensed under its MIT license.

License