🚀 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.1
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.

Example

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

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

  • Author - Nytyr

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