npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@arcblock/ocap-js

v0.34.3

Published

Javascript SDK for OCAP Service by ArcBlock

Downloads

29

Readme

ocap-js

build status code coverage styled with prettier license

Javascript SDK for OCAP Service by ArcBlock for both Node.js, browser and react-native.

If you are using this SDK in browser environment, babel-polyfill is required.

中文版文档,请移步这里.

Table of Contents

Notes

Since @arcblock/ocap-js v0.11.0, we support user specific rate-limit and page size limit on signed data request, instructions and code snippets to perform signed requests can be found here.

For security reasons, signed requests are only supported in node.js by now, if you want to leverage increased rate-limit and page sizing limit in the browser, consider building an API proxy layer in your DApp.

Install

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

Usage

const OCAPClient = require('@arcblock/ocap-js');

// init client
const client = new OCAPClient({
  dataSource: 'eth', // btc, eth
});

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

// raw query
const result = await client.doRawQuery(`{
  blockByHeight(height:5027689) {
    time
    size
    gasUsed
    gasLimit
    nonce
    reward
    preHash
    size
  }
}`);
console.log('RawQuery', result);

// paged result with shortcut query
const blocks = await client.listBlocks({
  timeFilter: {
    fromHeight: 1000000,
    toHeight: 1000020,
  },
  paging: { size: 5 },
});
console.log('PagedQuery.1', blocks.data.map(x => x.hash));
if (typeof blocks.next === 'function') {
  const blocks2 = await blocks.next();
  console.log('PagedQuery.2', blocks2.data.map(x => x.hash));
}

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

// raw subscription
const rawSubscription = await client.doRawSubscription(`
  subscription {
    newBlockMined {
      height
      hash
    }
  }`);
rawSubscription.on('data', data => console.log('RawSubscription', data));

Want more examples?

Documentation

Starter Templates

Start building OCAP DApp with just one command.

CodeSandbox Projects

Start building OCAP DApp without setting up environment.

OCAP Service CheatSheet

Contributors

| Name | Website | | -------------- | -------------------------- | | wangshijun | https://ocap.arcblock.io |

License

MIT © wangshijun