I wanna know how to send the transaction in spesific block numbers with web3js ( Yes its for sniping bot )

The purpose is to avoid the tax in 1-3 blocks since liquidity is added

For example :

New token are going to launch and having an anti sniper by putting those people or bots who are buying in 1-3 blocks from addliquidity transaction with a high tax

Addliquidity is added in 11008801 and the block on 11008801-11008803 having a high tax

how can i skip those blocks and send my transaction at 11008804 blocks ?

Someone told me to just add a delay with second , but im afraid that huge project launch will messing the second ( is it ? )

because from what i know is 1 block = 3 second and yeah im afraid if i put the delay by second for example im guessing that 3 second is 1 block but if the token are hyped and lot of transaction into it , maybe it will messing the second like 3 second become 10 block or more

sorry for my bad english , and thank you.

2 Answers 2


if it is for basic dApp requirement, you can use web3.eth.getBlockNumber(). Please let me share an example code snippet available on GitHub from a recently updated repository.

getPastLockboxSoldEvents: async function (pastBlockCount) {
            if (this.contract) {
                let events = await this.contract.getPastEvents('LockboxSold', {
                    fromBlock: await web3.eth.getBlockNumber() - pastBlockCount,
                    toBlock: 'latest'

                for (let i = 0; i < events.length; i++) {
                    let event = events[i];

                    event.transactionDate = new Date((await web3.eth.getBlock(event.blockNumber)).timestamp * 1000);

                    event.returnValues.id = event.returnValues.id.substring(0, 34);
                    event.returnValues.price = parseFloat(web3.utils.fromWei(event.returnValues.price));

                return events;

There is no way to determine in which block your transaction is mined.

The transaction order depends on the miner configuration, transaction nonce, etc. Nothing that you can determine in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.