How can I prove the existence of a function in a smart contract with the EstimateGas ? Thanks.


No, it is not possible to use estimateGas to determine in all cases the presence of a function.

If a function is not present it will invoke the fallback function. If it doesn't fail it will appear the function is working, but there's no function at all.

Other functions require specific parameters to work and they will fail if you do not send correct ones.

For some cases, for example if you suspect a contract to be an ERC20, you can check for specific functions like balanceOf, decimals etc.


I put estimateGas instead of .send or .call in the function and it works. Source: https://web3js.readthedocs.io/en/v1.2.1/web3-eth-contract.html#methods-mymethod-call

Object: The transaction object:

Array - arguments: The arguments passed to the method before. They can be changed. Function - call: Will call the “constant” method and execute its smart contract method in the EVM without sending a transaction (Can’t alter the smart contract state). Function - send: Will send a transaction to the smart contract and execute its method (Can alter the smart contract state). Function - estimateGas: Will estimate the gas used when the method would be executed on chain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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