Solidity – What Happens if Calling Non-existent Function Without Fallback?

fallback-functionsolidity

Let's say you call a function at another contract in Solidity:

contractB.doFunction()

It would then match it using the function signature to run the function in contractB. If there's not match, it would run the fallback function.

But if neither exists? What happens? Does it throw an error, or would you just expend the cost of the CALL?

Best Answer

The call will simply return immediately. There will be no code executed, but any value sent with the transaction will remain with the recipient contract. In fact, it will be as if you just sent ether to the contract (note that the value of the transaction can be 0). All extra data (including the ABI) will be ignored.