Hey @tungtien
Sorry for the long response
Last time when Iāve checked it, it didnāt work. Iāll check it again
Hey @tungtien
Sorry for the long response
Last time when Iāve checked it, it didnāt work. Iāll check it again
Hey @tungtien
You can get pending transactions using speedy nodes. I reccomend you to use websocket connection.
const nodeUrl =
"wss://speedy-nodes-nyc.moralis.io/xxxxxxxxxxx/bsc/mainnet/ws";
const provider = new Web3.providers.WebsocketProvider(nodeUrl);
const web3 = new Web3(provider);
let subscription = web3.eth.subscribe('pendingTransactions', function (error, result) {
if (result) {
console.log(result)
} else if (error) {
console.log(error);
}
});
If you want to recieve more info you can use:
let subscription = web3.eth.subscribe('pendingTransactions', function (error, result) {
if (result) {
web3.eth.getTransaction(result, function (error, transaction) {
console.log(transaction)
})
} else if (error) {
console.log(error);
}
});
Happy BUIDLing
Thank you Yomoo! I will try thatā¦
@Yomoo ,
But there is no Speedy-nodes URL for BSC Testnet right? I need the BSC testnet for developmentā¦
And, Will this method works for clouds functions?
my Bad, I found it. thank you!
@Yomoo,
on clouds function, if I call
_WEB3 = await Moralis.web3ByChain(networkId);
is it also using speedy-nodes ?
Most likely we are using speedy-nodes but will confirm this nevertheless.
Is there any way I can use this method for Clouds Functions?
when we use the web3.eth.getTransaction method, does it will cost us a request ?
Because in this case, it have a lot of pending transactions and with the 3500 request / min limitation on moralis, node server cant follow
Getting transactions from a node or with the api will use request
Dear @cryptokid,
const subscription = web3.eth.subscribe(āpendingTransactionsā, async (err, res) => { });
I am getting the following error after 6-7 requests with the method.
UnhandledPromiseRejectionWarning: Error: CONNECTION ERROR: Couldnāt connect to node on WS.
I would recommend to use another node provider.
On what chain happens that?
I am struggling with speedy nodes waiting from bsc network.
I used this code now and I got a lot of transaction hashes without an error
const nodeUrl =
"wss://speedy-nodes-nyc.moralis.io/4324/bsc/mainnet/ws";
const provider = new Web3.providers.WebsocketProvider(nodeUrl);
const web3 = new Web3(provider);
let subscription = web3.eth.subscribe('pendingTransactions', function (error, result) {
if (result) {
console.log(result)
} else if (error) {
console.log(error);
}
});
anyway, you will get into issues when trying to get the exact transactions for those transaction hashes
you also have add some config to automatically reconnect
we still recommend to use a different node provider
What can I use? Do you have a suggestion?
Can I do it with Moralis?
chainstack is an option: https://moralis.io/largenodes
there will be changes to speedy nodes in the near future:
Dear @cryptokid,
As far as I understand, we will be able to access the transactions that took place in the last 15 minutes from the speedy nodes paid and methods. Do I understand correctly?