I have migrated a contract using truffle to Rinkeby through Infura, it went up successfully, and I can interact with it in our dApp using Web3js v0.20.7, specifically the Events.
I would also like to query events using node on a scheduler, so I have this using web3 v1.2.2
const Web3 = require(“web3”);
var cryptozArtifact = require(’./Cryptoz.json’)
const rinkebyCryptoz = “0x822ee9b5d26a45a37885dd2b5a56c45b710c9548”;
let web3 = new Web3(
// Replace YOUR-PROJECT-ID with a Project ID from your Infura Dashboard
new Web3.providers.WebsocketProvider(“wss://rinkeby.infura.io/ws/v3/MY_PROJECT_ID”)
);
const instance = new web3.eth.Contract([cryptozArtifact], rinkebyCryptoz);
instance.getPastEvents(
“AllEvents”,
{ fromBlock: 0, toBlock: “latest” },
(errors, events) => {
if (!errors) {
// process events
console.log(events);
//console.log(JSON.stringify(events, null, 4));
}
}
);
The event logs look like this
{
address: ‘0x822eE9b5D26a45a37885dd2B5A56C45b710C9548’,
blockHash: ‘0x575e4ab2e174e2a1ea24fea3a434c083ec9aa53b3154f5c1fb5344faf4d6fe51’,
blockNumber: 7319169,
logIndex: 2,
removed: false,
transactionHash: ‘0xf4c9b02e451c0e63c1bf66a19869c938f6419e9c37aec01537c3ebce247337b5’,
transactionIndex: 2,
id: ‘log_e00cafdb’,
returnValues: Result {},
event: undefined,
signature: null,
raw: {
data: ‘0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b42726f776e204c656d7572000000000000000000000000000000000000000000’,
topics: [Array]
}
},
and I can’t filter by events I have emitted like LogCardCreated
Error: Event “LogCardCreated” doesn’t exist in this contract.
Any ideas ? thanks !