neo-js

A package for running a full or light node of the neo blockchain.

  • 所有者: CityOfZion/neo-js
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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

主要指标

概览
名称与所有者CityOfZion/neo-js
主编程语言TypeScript
编程语言JavaScript (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2017-09-06 00:34:21
推送于2020-11-24 23:36:17
最后一次提交2019-08-28 10:54:42
发布数15
最新版本名称0.14.0 (发布于 2018-12-30 02:24:12)
第一版名称v0.0.1 (发布于 )
用户参与
星数70
关注者数13
派生数32
提交数477
已启用问题?
问题数63
打开的问题数4
拉请求数133
打开的拉请求数4
关闭的拉请求数8
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?