neo-api

1.0.3 • Public • Published

neo-api

NEO JavaScript API for connecting to a NEO Network.

NEO JavaScript API

Interface methods provide access to JSON-RPC NEO Nodes as well as Rest Services to AntChain and Neon.

Available on npm

Documentation

Building

npm run build

Creates two bundles: One for node module dist/neo.node.js and one for the Browser dist/neo.js

Installing

Each bundle is a UMD module and supports AMD, CommonJS, and vanilla environments. Developers can create a custom bundle using Rollup or any preferred bundler.

Usage

NodeJS

var neo = require('neo.node.js');

HTML:

<script src="neo.js"></script>

Use neo object in your JavaScript environment.

var localNode = neo.node('http://localhost:10332');
localNode.getBlockCount().then(function (result) {
    console.log('Current block height: ' + result);
});
localNode.getLastBlockHash().then(function (result) {
    console.log('Hash of last block: ' + result);
});
var options = {
    baseUrl: 'http://www.antchain.org/api/v1/',
    transform: neo.transforms.antchain
};
neo.antChain(options).getAddressValue('AQVh2pG732YvtNaxEGkQUei3YA4cvo7d2i').then(function (addressValue) {
    console.log(addressValue.antShare.value);
    console.log(addressValue.antCoin.value);
});

More examples coming soon!

Test

Run all the Tests:

npm test

Run only the REST API tests:

npm test test/rest.api.js

Run only the JSON-RPC API tests:

npm test test/rpc.api.js

Readme

Keywords

Package Sidebar

Install

npm i neo-api

Weekly Downloads

0

Version

1.0.3

License

ISC

Last publish

Collaborators

  • ffox77