View Source Ethex.Abi.Event (ethex v0.1.3)

"https://mainnet.infura.io/v3/{{INFURA_API_KEY}}"

%{ address: ["0x497c41e4d95e9738bde7f23977e22d875de8fbd4"], fromBlock: "0xF83845", toBlock: "0xFA3845" }

Link to this section Summary

Functions

decode given logs using given function selectors.

Generate fromBlock and toBlock params according to current block num

combine eth_getLogs with decode, using the given abi_name, which MUST register in Abi genserver.

Link to this section Functions

@spec decode(list(), [ABI.FunctionSelector.t(), ...]) :: list()

decode given logs using given function selectors.

discard log when no function_selector match its method_id.

Link to this function

decode_log(log, selector)

View Source
@spec decode_log(map(), ABI.FunctionSelector.t()) :: map()
Link to this function

gen_block_range(rpc, last_block)

View Source
@spec gen_block_range(String.t(), non_neg_integer() | String.t()) :: any()

Generate fromBlock and toBlock params according to current block num

  1. when last_block == latest, fetch from newest back to 20 blocks.
  2. when cur_block - last_block > 800, fetch from last_block forwards 800 blocks.
  3. else, cur_block - last_block > 800, fetch from last_block to cur_block.

NOTE: the max block range in Polygon is 1000, in BSC is 5000.

Link to this function

get_logs_and_decode(rpc, abi_name, filter)

View Source
@spec get_logs_and_decode(String.t(), String.t(), map()) ::
  {:error, any()} | {:ok, list()}

combine eth_getLogs with decode, using the given abi_name, which MUST register in Abi genserver.

NOTE: address in filter SHOULD match abi_name, or will be discard.