Closed omarmoukiAtechy closed 2 years ago
Using pendingTransactions
method, you can receive all pending transactions with the stream
If you want to track a specific transaction whether it has been confirmed or not you can use Timer.periodic
to check your transaction every second with getTransactionByHash
(This method is mostly executed when your transaction is pending, and you will notice that the transaction is in the network, or it is pending or there is an error) or getTransactionReceipt
( This method works only when your transaction is in the block ), You can also use addedBlocks
method instead of a timer, this will give you a stream and inform you when new block created, you can track your transaction with the above methods when you receive new block message
thank you for your explanation, but I don't why the pendingTransactions
returns an error.
the error is RPCError (RPCError: got code -32601 with msg "The method eth_newPendingTransactionFilter does not exist/is not available".)
and my code is:
void initialSetup() {
httpClient = http.Client();
// String url = "https://rinkeby.infura.io/v3/" + (dotenv.env['PROJECT_ID'] ?? "");
String url = "https://rinkeby.infura.io/v3/" +
(dotenv.env[AppStrings.Env_CONTRACT_PROJECT_ID]!);
rpc = JsonRPC(url, httpClient);
ethClient = Web3Client.custom(rpc, socketConnector: () {
return IOWebSocketChannel.connect(
"wss://rinkeby.infura.io/ws/v3/${dotenv.env[AppStrings.Env_CONTRACT_PROJECT_ID]!}/")
.cast<String>();
});
}
ethClient.pendingTransactions().listen((event) {
log(event);
});
I don't know if I am doing something wrong or there's an error with the package
when you get an error like filter or method doest not exist its related to your rpc url
most more RPC URL doest not work with stream or filterChanged
like infura, use moralis api
Thank you very much that was super helpful.
is this package supports transaction subscription? same as web3.eth.subscribe in web3.js if it already supports it, how can I implement it. and if not, is there a workaround?