Here's a example of setting an infura provider using truffle-hdwallet-provider with a custom wallet:
const HDWalletProvider = require('truffle-hdwallet-provider')
const fs = require('fs')
const mnemonic = process.env.MNEMONIC
module.exports = {
networks: {
development: {
host: 'localhost',
port: 8545,
gas: 4500000,
gasPrice: 25000000000,
network_id: '*'
},
kovan: {
provider: new HDWalletProvider(mnemonic, 'https://kovan.infura.io'),
network_id: '*',
gas: 4500000,
gasPrice: 25000000000
},
rinkeby: {
provider: new HDWalletProvider(mnemonic, 'https://rinkeby.infura.io'),
network_id: '*',
gas: 4500000,
gasPrice: 25000000000
},
mainnet: {
provider: new HDWalletProvider(mnemonic, 'https://mainnet.infura.io'),
network_id: '*',
gas: 4500000,
gasPrice: 25000000000
}
}
}
Then just set the network option when deploying:
truffle migrate --reset --network=rinkeby
In the UI, here's how to set the Web3 HTTP provider to infura:
if (typeof web3 !== 'undefined') {
window.web3 = new Web3(web3.currentProvider)
} else {
window.web3 = new Web3(new Web3.providers.HttpProvider('https://rinkeby.infura.io:443'))
}
Summary
The node (geth) is deleting the filter, maybe due to inactivity, so returns filter not found
for that ID.
Why?
Informally, filters work over json-rpc work like so:
- Send to node: "Create a filter with parameters X, Y, Z"
- Node replies: "Filter installed, with ID 456"
- Send to node: "Any new information on filter ID 456?"
- Node replies: "Yes, these changes: [...]"
- Time passes...
- Node decides to uninstall filter 456
- Send to node: "Any new information on filter ID 456?"
- Node replies: "I have no record of filter 456"
Unfortunately, the spec doesn't have much to say about when the node is allowed to uninstall the filter. The node can do it at will, and without notice. So in the end, the only thing you can do is check for the error, and recreate the filter if it is gone... (ugh, I know)
Web3.py plans
There is an open issue to stop using that json-rpc filter mechanism altogether, and keep all the filter state on the web3.py side. It was inspired by exactly the issue that you brought up.
Best Answer
Infura doesn't support filters.
Per https://api.infura.io/v1/jsonrpc/ropsten/methods (from the documentation, these are the supported methods: