Hello
I'm getting this error while listening for new pending transactions, or even if I'm using subscribe_logs with a filter, but right now I'm showing code example for the new pending transaction filter.
use std::env;
use tokio::*;
use web3::*;
use futures::stream::StreamExt;
use web3::contract::tokens::Tokenize;
use web3::transports::ws::WebSocket;
use web3::types::{TransactionId, Transaction, H256};
async fn list(pendingtx: H256, web3s: Web3<WebSocket>) -> Option<Transaction> {
let tx = match web3s
.eth()
.transaction(TransactionId::Hash(pendingtx))
.await
{
Ok(Some(tx)) => return Some(tx),
_ => {
return None;
}
};
}
#[tokio::main]
async fn main() -> web3::Result {
// Loading the .env file
dotenv().expect("Failed to read .env file");
// Make the node connection
let api_link = &env::var("NODE_LINK").expect("NODE_LINK must be set");
let transport = web3::transports::WebSocket::new(&api_link).await?;
let web3s = web3::Web3::new(transport.clone());
// Setup the subscription stream for new pending transactions
let mut subscription = web3s
.eth_subscribe()
.subscribe_new_pending_transactions()
.await?;
loop {
while let Some(pendingtx) = subscription.next().await {
let listed = list(pendingtx.unwrap(), web3s.clone());
tokio::spawn(async move {
match listed.await {
Some(result) => {
println!("Transaction sent from: {:?}", result.from.unwrap());
println!("------------------------------------------------------------");
}
None => (),
}
});
}
// If the next value in the subscription is None, then make a new subscription stream
subscription = web3s
.eth_subscribe()
.subscribe_new_pending_transactions()
.await?;
println!("New subscription made!");
}
Ok(())
}
And I tried out multiple free tier node service and basically all doing the same error. Not sure because of the heavy stream not allowed in free tier or because of the web3 crate I'm experiencing this problem. But because in issues #642 had similar problem I think it's might web3 crate connected error.
Hello I'm getting this error while listening for new pending transactions, or even if I'm using
subscribe_logs
with a filter, but right now I'm showing code example for the new pending transaction filter.And I tried out multiple free tier node service and basically all doing the same error. Not sure because of the heavy stream not allowed in free tier or because of the web3 crate I'm experiencing this problem. But because in issues #642 had similar problem I think it's might web3 crate connected error.