ethjs / ethjs-contract

A simple contract object for the Ethereum RPC layer.
MIT License
20 stars 28 forks source link

Better Log features (comparible to web3) #12

Open SilentCicero opened 6 years ago

SilentCicero commented 6 years ago

Issue Type

Description

We want to be able to grab logs like web3. Just a getLogs kind of method, but with topic filtering:

Currently one has to do something like this:

eth.getLogs({
   address: 'CONTRACT_ADDRESS',
   topics: [`0x${Eth.keccak256(`${abi[0].name}(${abi[0].inputs.map(v => v.type).join(',')})`)}`],
})
.then(console.log);

We can bind that into that contract object like so:

contractObject.filterName.getLogs with the contract address and topic array predefined/filled.

we can also pre-define the topic name output as so:

contractObject.fitlerName.topic which will produce the sha3 hash.