Reference
Extractor module
// NOTE: address and topics can be used to filter events at the Ethereum node
// level.
function init({ args: {start = 0, end, address, topics, blockspan = 1}})
startStart block as a natural number in decimal-base (default: 0).endEnd block as a natural number in decimal-base.address“0x”- prefixed Ethereum address of where an event log originates from.topicsArray containing up to three 32 byte long “0x”-prefixed topic hashes related to the event or an array of arrays containing such values.blockspanThe distance betweenfromBlockandtoBlockin decimal-base (default: 1).includeTimestampFlag to include the block timestamp asblock.timestampin the result object.includeValueFlag to include the transaction’s value astransaction.valuein the result object.
Transformer module
function onLine({args: {topics = [], address, inputs}, state: {line}})
lineIs an argument defined by@attestate/crawlerinternally. It is a line within the strategy’sinput.pathfile.address“0x”- prefixed Ethereum address of where an event log originates from.topicsArray containing up to three 32 byte long “0x”-prefixed topic hashes related to the event or an array of arrays containing such values.inputsWhen defined, it replaces the event log’s “data” property with a parsed event log using web3-eth-abi@1.4.0’s decodeLog.
Loader module
function* order({state: {line}})
lineIs an argument defined by@attestate/crawlerinternally. It is a line within the strategy’sinput.pathfile.
order is a JavaScript generator function.
As the key, it concatenates serialized blockNumber and transactionIndex to
generate an identifier which defines a total order among transactionHash``es.
``value is the transactionHash.
function* direct({state: {line}})
lineIs an argument defined by@attestate/crawlerinternally. It is a line within the strategy’sinput.pathfile.
direct is a JavaScript generator function.
As the key, it defines the transactionHash to generate an identifier
which lets us directly access the log through value.
State module
The state module provides coordinator functionality for continuous blockchain
monitoring by polling eth_blockNumber over HTTP.
function watch({ environment, onNewBlock })
environmentObject containing environment variables (rpcHttpHost,pollingInterval) passed from the crawler configuration.onNewBlockCallback function invoked with the latest block number on every poll that sees a new block.
The watch() function polls eth_blockNumber on
environment.rpcHttpHost every environment.pollingInterval milliseconds
and returns an unwatch() function to stop polling.
environment.rpcHttpHost can be a single URL or a list of URLs. With a list,
each crawl sends its eth_getLogs requests to the next URL in turn, which
spreads the load across providers (e.g. to stay within several free tiers).
Note
Versions 0.6.x subscribed to newHeads via WebSocket
(environment.rpcWsHost). Since 0.7.0, watch() polls over HTTP
instead, because many providers bill every newHeads event.