Among other things, every Ethereum transaction has attribute named
gasLimit or simply
gas. This is the maximum amount of gas transaction is allowed to consume. When sending transaction via Web3 API, you may specify value for this attribute explicitly:
gas: 90000 // <-- Here is gasLimit
This parameter is optional, and if it is omitted, Web3 API implementation will try to estimate proper value by first executing transaction locally before actually broadcasting it to the network. This local execution is similar to how miners execute transaction before including them into blocks.
In case local execution succeeds, Web3 API implementation counts how much gas transaction actually consumed and uses this value to populate
gasLimit parameter. Though, in case local execution failed, e.g. smart contract reverted it,
gas estimation failed error is reported. You may still broadcast such transaction by explicitly specifying
gasLimit for it.