In some hot presale, IDO, ILO,⌠itâs literally a gas war and a lot of transaction will be send to bsc node in that time lead to congestion. Some of my tx was like âignoredâ, itâs not appeared in bscscan although my gas gwei is pretty high. Anybody know how bsc validator work like the maximum capacity of mempool, how it prioritizes transactions,âŚ
And when my tx is reverted by the evm, it just throw âError: Transaction has been reverted by the EVMâ and an object like this:
{ âblockHashâ: â0x901bc06579c0054aaecd1da708fa83e56f3d9fd3ea920ad76e73ba0fc5746164â, âblockNumberâ: 10649933, âcontractAddressâ: null, âcumulativeGasUsedâ: 19952894, âfromâ: â0x3b4f8c05b11d106d32dd7b2acd6f4a464695285eâ, âgasUsedâ: 34626, âlogsâ: [], âlogsBloomâ: â0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000â, âstatusâ: false, âtoâ: â0xc06ac1b96609fb8b01e3cb64d19fcbd6605039e3â, âtransactionHashâ: â0xc2b643e34f4bf2ed71c0e3c029915f8053cb477f8560283bfdae9068b50a89aeâ, âtransactionIndexâ: 123, âtypeâ: â0x0â }
I donât know how to debug with the same error like this everytime my tx is failed.
Sorry for my bad english
I know, but I is there any way to show that âNOTHING TO WITHDRAWâ in my throw exception?
I know only how to do it in python for now:
from web3 import Web3
speedy_node = 'https://speedy-nodes-nyc.moralis.io/vvvvvvvvvv/bsc/mainnet/archive'
web3 = Web3(Web3.HTTPProvider(speedy_node))
print(web3.isConnected())
from_ = web3.toChecksumAddress('0x3b4f8c05b11d106d32dd7b2acd6f4a464695285e')
to_ = web3.toChecksumAddress('0xc06ac1b96609fb8b01e3cb64d19fcbd6605039e3')
try:
y = web3.eth.call({
'from': from_,
'to': to_,
'data': '0xfe8121de'}, block_identifier=10649933)
except Exception as e:
print(repr(e))
=> ContractLogicError('execution reverted: NOTHING TO WITHDRAW')
Hey @spider149
Take a look at:
https://web3js.readthedocs.io/en/v1.2.5/web3-eth.html#handlerevert
web3.eth.handleRevert = true;
try {
await contract.methods.method().call();
} catch (e) {
const data = e.data;
console.log(data)
}
Thank you all for answering me, If you are using python, try @cryptokid solution, Iâm not checking it yet And if you are using js and have the same problem with me, set web3.eth.handleRevert to true, but in my case, my exception not have âdataâ field, instead it have âreasonâ field, you can log the full err to get all of its field.
But Iâm still wondering about âBSC congestionâ, may I will try it tonight when a hot IDO launch, I will reply this comment if I know the answer.
Update: I donât know why, but with handlerevert, some return the âreasonâ field, some not although in bscscan, itâs show the error clearly.
You may have to specify the block_identifier
parameter in some cases, and you may have to use an archive node if you are not using that. [only if you try to do transaction replay]
I just want to log clear reason for user when a transaction is failed, with js try catch, I can only get âTransaction has been reverted by the EVMâ, and itâs hard to debug.
python HTTP POST request version:
import requests
import json
headers = {
"Content-Type": "application/json"
}
speedy_node = 'https://speedy-nodes-nyc.moralis.io/vvvvvvvvv/bsc/mainnet/archive'
post_data = '{"jsonrpc": "2.0", "method": "eth_call", "params": [{"from": "0x3B4F8C05b11D106D32Dd7B2acd6F4a464695285e", "to": "0xC06aC1B96609FB8B01E3cB64D19fcBd6605039e3", "data": "0xfe8121de"}, "0xa2814d"], "id": 1}'
statusResponse = requests.request("POST", speedy_node, headers=headers, data=post_data)
data = statusResponse.json()
print(json.dumps(data, indent=4))
=>
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": 3,
"message": "execution reverted: NOTHING TO WITHDRAW",
"data": "0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000134e4f5448494e4720544f20574954484452415700000000000000000000000000"
}
}
maybe itâs just show the full error with archive mode, is there any difference between a normal node and archive node? thank you.
I think that a regular node keeps only last N minted blocks.