NEO JavaScript API for connecting to a NEO Network.
This api library is currently being used by Neo Network Status Monitor (NeoMon)
Interface methods provide access to JSON-RPC NEO Nodes as well as Neo REST service providers. This is a barebones API framework providing wrappers around commonly known NEO endpoints. No crypto libraries for reading / writing transactions are provided. The framework is intended to be used for getting state information from service end points. The APIs for writing transactions may be included but the capability to write and sign those transactions is left up to other frameworks.
Available on npm
npm run build
Creates two bundles: One for node module dist/neo.node.js
and one for the Browser dist/neo.js
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.
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.getBestBlockHash().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!
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