Skip to content
/idxsPublic

TypeScript Interface for Index Supply

License

Notifications You must be signed in to change notification settings

wevm/idxs

Repository files navigation

idxs

TypeScript Interface for Index Supply.

Install

npm i idxs

Usage

IndexSupply

Instantiate and use the IndexSupply client to fetch data from the Index Supply API.

import{IndexSupply}from'idxs'constis=IndexSupply.create()// Fetch transactionsconsttxs=awaitis.fetch({query: 'select hash, "from", "to", value from txs where chain = 1 limit 10',})console.log(txs.rows)// Fetch Transfer events with ABI signatureconsttransfers=awaitis.fetch({query: 'select "from", "to", value from transfer where chain = 1 limit 10',signatures: ['event Transfer(address indexed from, address indexed to, uint256 value)'],})console.log(transfers.rows)// Pagination with cursorconstnext=awaitis.fetch({query: 'select hash, "from", "to", value from txs where chain = 1 limit 10',cursor: txs.cursor,})// Live streamingforawait(constresultofis.live({query: 'select hash, "from", "to" from txs where chain = 1 limit 10',}))console.log(result.rows)

QueryBuilder

idxs exports a Kysely-based type-safe query builder.

import{IndexSupply,QueryBuilder}from'idxs'constis=IndexSupply.create()constqb=QueryBuilder.from(is)// Query standard tablesconsttxs=awaitqb.selectFrom('txs').select(['hash','from','to','value']).where('chain','=',1).limit(10).execute()// Query with event signaturesconsttransfers=awaitqb.withSignatures(['event Transfer(address indexed from, address indexed to, uint256 value)']).selectFrom('transfer').select(['from','to','value']).where('chain','=',1).limit(100).execute()// Pagination with cursorconstnext=awaitqb.atCursor(txs.cursor).selectFrom('txs').select(['hash']).limit(10).execute()// Live streamingforawait(consttxsofqb.selectFrom('txs').select(['hash','from','to','value']).where('chain','=',1).stream())console.log(txs)

API

TODO

License

MIT

About

TypeScript Interface for Index Supply

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Contributors 3

  •  
  •  
  •