I'm trying to build a Javascript Bot subscribing to specific events on a contract, I have written some lines of code but I'm not sure how the EventEmitter returns data and how I can use it. Can anyone give me an example on how I can retrieve specific data (like transaction hash/ parameters of the event) each time web3.eth.subscribe() fires ?
Here's the code I've written :
const Web3 = require('web3')
const web3 = new Web3(new Web3.providers.HttpProvider("https://api.avax-
test.network/ext/bc/C/rpc") )
web3.eth.subscribe(
'logs',
{
address : 'some contract address',
topics : ['Keccak-256 hash(the event)']
},
function(error,result){
if(!error)
console.log(result);
}
)
.on("connected",function(subscriptionId){ //to check if subscription is successful
print(subscriptionId);
})