Hi, I know the group is focused on Solidity, but I have a problem that involves blockchain and I can't solve it. If anyone can help me, I'll be grateful.

I made the code below to get the pending blocks in the BNB Chain network, and now I'm trying to modify it to retrieve specific transaction hashes, but I can't.

Jun 5, 2023, 7:35 PM
If you dont have a own running node, that wont work
And most Node providers dont allow to use these functions either
Jun 5, 2023, 7:40 PM
I have a node, and this code works perfectly fine. I just can't modify it to filter by transaction.
Jun 5, 2023, 7:42 PM
If you use quicknode as your commeny says
The access to the mempool is blocked
As mentioned before
Had the same issue on a "getBlock" Node, till i was reading the docs, lol
Jun 5, 2023, 7:47 PM
Does it block transaction information?
Did you find a solution?
Jun 5, 2023, 7:48 PM
Only way is to get own root server and do own node

Maybe vserver is enough, gotta scale it pretty big
https://docs.bnbchain.org/docs/validator/fullnode/
https://medium.com/@pieterc/running-a-full-node-with-geth-bsc-610085141248
Jun 5, 2023, 9:33 PM
Were you able to get the pending transactions with your own server?
I was told that it is possible to obtain pending transactions with public rpc, you just need to do the code correctly.
Jun 5, 2023, 9:40 PM
Depends if your node if a fullnode or not
Jun 5, 2023, 9:40 PM
Can you explain better, I don't understand.
Jun 5, 2023, 9:43 PM
https://www.alchemy.com/overviews/full-vs-light-vs-archive-nodes

If you run your own node you can choose the kind of node.

Fullnode = All tx since genesis.

Lightnode = Only tx done in your RPC.
Jun 5, 2023, 9:45 PM
Ah yes, that's vdd, but my problem is not that at the moment, my problem is that my code is not fetching the transactions in process.
Jun 5, 2023, 9:49 PM
There are multiple transactions per block. You could iterate over them with a for loop.
Jun 6, 2023, 7:03 AM
Sorry, but I couldn't understand
Jun 6, 2023, 7:07 AM
What I am trying to say is you can use a for loop to iterate over all transactions in a block.
Here is the js equivalent:
// Iterate through the blocks between the starting block and the latest block
for (let blockNumber = startBlockNumber; blockNumber <= latestBlockNumber; blockNumber++) {
const block = await provider.getBlock(blockNumber, true);

if (block.transactions.length > 0) {
for (const transaction of block.transactions) {
console.log(transaction);
}
} else if(!block.transactions.length === 0){
console.log(`No transactions found in block ${blockNumber}. Skipping...`);
}
}
Jun 6, 2023, 7:30 AM
you say to look for transactions inside the blocks
Jun 6, 2023, 7:44 AM
Yeah I realize you need pending transactions. Then try an api from a provider that offers it or you can set up your own node.
Jun 6, 2023, 8:27 AM
Can you share some tips on setting up own node
Jun 6, 2023, 8:31 AM
I am struggling with it too, but there are some good tutorials on youtube.
Jun 6, 2023, 8:54 AM
Please share
Jun 6, 2023, 8:55 AM
I did find an api for it. Look up "rpc fast by dysnix". They have it for multiple blockchains and there is a free version as well.
For tutorials just lookup on youtube setup geth or geth-bsc
Jun 6, 2023, 9:10 AM
right, I'm trying to use quicknode.
Jun 6, 2023, 10:16 AM
Mmm, can you brief me on what you're trying to do and what is not working ?
Jun 6, 2023, 10:19 AM
I'm trying to fetch pending transactions for a specific contract
In bnb chain
Jun 6, 2023, 10:22 AM
Why are so many still using goerli ?
Oh okey, I only tried to fetch confirmed transactions but not pending ones. Works fine for me.
Jun 6, 2023, 10:43 AM
They're broke af
Jun 6, 2023, 10:45 AM
I mean, so many other good testnets
Jun 6, 2023, 10:46 AM
There should be an ethers filter for this
provider.on("pending")
This should fetch all the txs from mempool
You can later filter out required txs
Jun 6, 2023, 10:56 AM
Like?
Jun 6, 2023, 10:56 AM
Bsc, mumbai, sepolia...
Or the OG fork and test :)
Jun 6, 2023, 10:57 AM
mumbai is pretty good, sometimes I test on bsc. Also fuji.
Goerli is messed up now
https://sepoliafaucet.com/
Jun 6, 2023, 11:30 AM
Which is better, truffle or hardhat?
Jun 6, 2023, 1:04 PM
Hardhat is more widely supported
Jun 6, 2023, 1:18 PM
Have a look at foundry as well, it helped me get started
You don't need to know JS and do your tests in solidity
Jun 6, 2023, 1:23 PM
Thanks will give it a try
Jun 6, 2023, 1:23 PM
I only code solidity with foundry personally. Haven't used the other two.
Jun 6, 2023, 1:23 PM
If you got any solidity-related question, don't ask to ask, just ask directly.
Someone will reply, maybe
it's not suggested to fork contracts if you don't know at least what they do or how to configure them
Jun 6, 2023, 2:13 PM
maybe i could pm you for some extra help? willing to pay
Jun 6, 2023, 2:13 PM
sure
expect it to go exponential once the bull run starts again
i just hope they won't fuck the whole system up for being a greedy human
https://docs.openzeppelin.com/contracts/4.x/wizard
Jun 6, 2023, 3:24 PM
Can you please share a few links to understand tokenomics and how to set tax for a smart contract
Jun 6, 2023, 4:04 PM
https://bscscan.com/address/0x74f08af7528ffb751e3a435ddd779b5c4565e684#code#F6#L1
whole _transfer is commented, read it and understand it
Jun 6, 2023, 4:06 PM
Thanks!
Jun 6, 2023, 4:06 PM
You could have used variable packing to save sstores
& ssloads too
Also all those mappings... Gas bad😅
Jun 6, 2023, 4:37 PM
true, that's why it's on bsc =)
i prefeer a clear readable contract but not optimized, on a low-fee chain (mostly because i'm still a noob in true optimization😂)
Jun 6, 2023, 4:38 PM
Gas optimization is chain agnostic
It wouldn't have impacted readibility😅, I just took a quick glance and noted a few stuff
Jun 6, 2023, 4:39 PM
feel free to write me those improvements o/
Jun 6, 2023, 4:40 PM
You could have saved a lot packing single variables and turning the multiple address->bool mappings into for example a address->(bool,bool,bool) mapping
I stopped reading there
Jun 6, 2023, 4:41 PM
use forks
https://t.me/dev_solidity/244117
Jun 6, 2023, 4:58 PM
I need pancake v2 running on my testnet, due to low time, i didn't want to build my own swap,just want to running with testnet pancakes
Jun 6, 2023, 4:59 PM
you don't have to build your own swap
with forks you can use the pancake on mainnet, so the contract will be 1:1 with what you will deploy on mainnet
Jun 6, 2023, 5:00 PM
It's just 2 contract deployments, 3 if you count weth
Jun 6, 2023, 7:35 PM

© 2024 Draquery.com All rights reserved.