🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

query3

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

query3

Query data from smart contracts.

0.0.3
latest
Source
npm
Version published
Weekly downloads
3
50%
Maintainers
1
Weekly downloads
 
Created
Source

🔎 ⛓ Query3.js

Query3 is a javascript library for storing smart contract events locally and do complex queries, like sorting, conditions and more.

It features two storage implementations, IndexedDB for running the library on the browser and SQLite when running it server-side.

🛠 Installation

npm install query3 --save

⭐️ Features

  • Event syncing: Stores events locally, continue the syncing where you paused.
  • Multi chain: Chain agnostinc.
  • Multiple storage implementations: Use our IndexedDB, SQLite implementation or create your own one.
  • Fast sync

👨‍🚀 Example

const query3 = new Query3(
    erc20Address,
    erc20Abi,
    ['Transfer', 'Approve'],
    new InfuraProvider('mainnet', infuraApiKey),
    startBlock
);
await query3.sync();
const events = await query3.getEvents('Transfer');

You can find more examples on the "demos" folder.

📖 Complex queries

const query3 = new Query3(
    erc20Address,
    erc20Abi,
    ['Transfer', 'Approve'],
    new InfuraProvider('mainnet', infuraApiKey)
);
await query3.sync();
const limit = 100;
const offset = 0;
const orderBy: OrderBy = {
    field: 'value',
    strategy: 'DESC'
};
const conditions: WhereCondition[] = [
    {
        key: 'from',
        value: '0x000',
        comparator: '='
    }
];
const events = await query3.getEvents(
    'Transfer', 
    conditions,
    orderBy,
    limit,
    offset
);

⚙️ Full Config

const query3 = new Query3(
    address,
    abi,
    ['Transfer'],
    new RpcProvider('https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161'),
    startBlock,
    new StandardEventParser(abi),
    new IndexedDb("IndexedDb")
)

Stay in touch

Keywords

web3

FAQs

Package last updated on 03 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts