1

In what circumstances a test can fail with the error "Contract does not have fallback nor receive functions" ?

My contract already contains both a fallback and a receive function:

event Received(address, uint);
receive() external payable {
    emit Received(msg.sender, msg.value);
}

fallback() external payable {

}

I am using solodity 0.8.0.

3
  • 1
    Calling the wrong contract ? It happened to me once
    – Majd TL
    Aug 19 at 21:23
  • Your example compiles just fine when placed inside a contract. Can you provide a self-contained example that reproduces this error when compiled with solc?
    – cameel
    Aug 28 at 19:13
  • What was the test doing? Are you sure the error is related to that contract?
    – Ismael
    Aug 30 at 7:04

Your Answer

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

Browse other questions tagged or ask your own question.