Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including @cityofzion/neo-js with all npm packages installed. Try it out:

var neoJs = require("@cityofzion/neo-js")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@cityofzion/neo-js v0.14.0

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

City of Zion logo


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

npm version


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


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+


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://

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', () => {
    .then((res) => {
      console.log('Testnet getBlockCount:', res)

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

mainnetNeo.mesh.on('ready', () => {
    .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'ready', () => {
    .then((res) => {
      console.log('Block height:', res)


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


Please refer to Optional Parameters document


Please refer to Event Emitters document


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.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free