@arcblock/node-ocapdeprecated

Node.js SDK for OCAP Service by ArcBlock

Usage no npm install needed!

<script type="module">
  import arcblockNodeOcap from 'https://cdn.skypack.dev/@arcblock/node-ocap';
</script>

README

@arcblock/node-ocap

build status code coverage code style styled with prettier made with lass license

Node.js SDK for OCAP Service by ArcBlock

Table of Contents

Install

npm install @arcblock/node-ocap
// or
yarn add @arcblock/node-ocap

Usage

const OcapSDK = require('@arcblock/node-ocap');

// init client
const client = new OcapSDK({
  httpBaseUrl: 'https://ocap.arcblock.io/api', // we may have multiple hosts in future
  socketBaseUrl: ds => `wss://ocap.arcblock.io/api/${ds}/socket`,
  dataSource: 'eth', // btc, eth
});

// list api
const queries = client.getQueries();
const subscriptions = client.getSubscriptions();
const mutations = client.getMutations();

// query
const account = await client.accountByAddress({
  address: '0xe65d3128feafd14d472442608daf94bceb91e333',
});

// subscription
const subscription = await client.newBlockMined();
subscription.on('data', data => console.log(data));

See docs/example.btc.js for Bitcoin examples. See docs/example.eth.js for Ethereum examples. See docs/spec.md for full api support.

Documentation

Contributors

Name Website
wangshijun https://ocap.arcblock.io
  • wangshijun

License

MIT © wangshijun