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

buidlhub-query-api

v0.1.2

Published

Query library for BUIDLHub

Downloads

4

Readme

query-api

To use this library, you will first need an API key from https://buidlhub.com. Sign up, register at least 1 dApp and get your key. This will be needed to initialize the BHubClient.

Installation

npm install buidlhub-query-api

Usage

   import {
      BHubClient,
      Filter
   } from 'buidlhub-query-api';
   
   ...
   
   //initialize the client with an api key 
   let client = await BHubClient.init({
      apiKey: <API_KEY>
   });
   
   //create a complex filter to find transactions for the Idex contract. 
   //NOTE: it is assumed that the Idex contract ABI is registered with your
   //dApp on BUIDLHub.
   
   //here we want to filter out transactions that are either successful and depositToken calls OR transactions that 
   //have a Deposit or Withdraw event with specific attributes.
   let filter = Filter.or([
      Filter.and([
        //only transactions where the function is 'depositToken' for a specific token address
        Filter.functionQuery({
          name: 'depositToken',
          params: {
            token: "0x50ee674689d75c0f88e8f83cfe8c4b69e8fd590d"
          }
        }),
        
        //only transactions that succeeded
        Filter.fields({
          status: true
        })
      ]),
      Filter.or([
        //or transactions that have a 'Withdraw' event with a specific token attribute
        Filter.eventQuery({
          name: "Withdraw",
          attributes: {
            token: "0x1844b21593262668b7248d0f57a220caaba46ab9"
          }
        }),
        //or transactions that have a 'Deposit' event with a specific token attribute
        Filter.eventQuery({
          name: "Deposit",
          attributes: {
            token: "0x50ee674689d75c0f88e8f83cfe8c4b69e8fd590d"
          }
        })
      ])
    ]);

    //create a query
    let query = client.query({
    
      //for these contract addresses
      contracts: [
        '0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208'
      ],
      
      //using the filter created above
      filter,
      
      //paging with 10 results per page
      limit: 10,
      
      //starting at page 0
      offset: 0
    });
    
    //execute async and get the results
    let results = await query.execute();
    
    //results.total holds total number of items that can be paged through
    //results.hits are the transactions of interest