I have been trying to observe the transactions taking place on mainnet for a specific contract, specifically Tether (USDT). I am able to download the contract and compile the solidity code with Web3 (Java). However I am unable to subscribe for transfer events. It just times out.. is there something I am missing? I am using the below code but get a timeout.
I can see no reason why this would not work, I connect through Infura via wss://mainnet.infura.io/ws/v3/<my_identifier_here>
TetherToken tetherToken = TetherToken.load(
"0xdac17f958d2ee523a2206206994597c13d831ec7",
session.getWeb3(),
session.getCredentials(),
session.getGasProvider());
String symbol = tetherToken.symbol().send();
String name = tetherToken.name().send();
BigInteger decimal = tetherToken.decimals().send();
System.out.println("symbol: " + symbol); // success = USDT
System.out.println("name: " + name); // success = Tether USD
System.out.println("decimal: " + decimal.intValueExact()); // success = 6
// java.io.IOException: Request with id 5 timed out
tetherToken.transferEventFlowable(DefaultBlockParameterName.EARLIEST, DefaultBlockParameterName.LATEST)
.subscribe(event -> {
try {
System.err.printf("hash=%s from=%s to=%s amount=%s%n",
event.log.getTransactionHash(),
event.from,
event.to,
event.value);
}catch(Throwable e) {
e.printStackTrace();
}
});
Any help would be greatly appreciated.