I have a smart contract in Remix and would like to be able to filter events using Infura. I know nothing on how to get started. I went to infura and created a project which has a project ID. What should I do next? How do I connect them together?
2 Answers
I don't know about the solution as a whole (event filtering), but I can help by connecting to Infura from Remix:
- Open "DEPLOY & RUN TRANSACTIONS" tab from the left panel (Eth logo and ">")
- In the "Environment" field choose "Web3 Provider"
- In the opened pop-up window put your Infura endpoint. Endpoint's example: "https://%NETWORK_NAME%.infura.io/v3/%PROJECT_ID%".
- Then you can deploy or import the contract.
you can not filter events with infura, but it is possible with web3, infura is RPC provider, follow this steps to interact with the contract:
1- create your API key with RPC provider (here is infura), user same network as your deployment network.(I recommend to user websocket in infura)
2-put your API key in .env and your network configuration in your network config(in truffle uncomment network in truffle-config.js)
3-read this question about web3 event filtering