kool-freelog

get your logs from Infura!

Usage no npm install needed!

<script type="module">
  import koolFreelog from 'https://cdn.skypack.dev/kool-freelog';
</script>

README

kool-freelog

This is a module intended to get a set of EVM logs from the blockchain, designed to work with a stubborn RPC such as Infura. In fact, the module defaults to using Infura, and allows you to use your own W3C WebSocket class or Promise implementation.

In addition to the standard log query, you can add a chunkSize field to determine how many blocks you want to fetch at a time. Smaller chunk sizes are slower but more reliable to get your logs fo' free.

NodeJS Usage


const { w3cwebsocket: WebSocket } = require('websocket');
const generateFreeLog = require('kool-freelog');
const freeLog = generateFreeLog(WebSocket, Promise, 'mainnet');
const { soliditySha3 } = require('web3-utils');

const logs = await freeLog({
  fromBlock: 1e6,
  toBlock: 1e6 + 1000,
  topics: [ soliditySha3('Transfer(address,address,uint256)') ],
  chunkSize: 100,
  concurrency: 5
});

/* logs contains all Transfer events for all ERC20 tokens */