'Hardhat – What are the strange calls to my smart contract?

I am using Hardhat hackathon boilerplate and calling my smart contract's (address 1c0, addresses shortened for clarity) function MyContract#addProduct from the UI via ethers.js.

The problem: I see bunch of weird function calls before and after I call my addProduct function. An account (266) doing these weird calls is a first address generated by HH upon starting. MyContract is deployed at 1c0.

Below is the log from Hardhat node terminal with my comments after //

What are these calls and where do they originate?

UPDATE: A suggestion from my friend that it can be MetaMask querying a smart contract for whatever purposes. Still gonna investigate it.

// I don't know who's calling it
eth_call 
  Contract call:       MyContract#<unrecognized-selector>
  From:                266
  To:                  1c0

// My fallback is logging
  console.log:
    MyContract: Fallback called 

// I don't know who's calling it
eth_call
  Contract call:       MyContract#symbol
  From:                266
  To:                  1c0

// I don't know who's calling it
eth_blockNumber
eth_getBalance (3)
eth_call
  WARNING: Calling an account which is not a contract
  From:                266
  To:                  e86

// This is what I call from UI
eth_getTransactionCount
eth_blockNumber
eth_sendRawTransaction 
  Contract call:       MyContract#addProduct
  Transaction:         740
  From:                5ab
  To:                  1c0
  Value:               0 ETH
  Gas used:            414218 of 414218
  Block #23:           925

  console.log:
    MyContract:addProduct()

eth_getTransactionReceipt
eth_blockNumber
eth_getTransactionReceipt
eth_blockNumber
eth_getBlockByHash

// I don't know who's calling it
eth_call
  Contract call:       MyContract#<unrecognized-selector>
  From:                266
  To:                  1c0

  console.log:
    MyContract: Fallback called

// I don't know who's calling it
eth_call 
  Contract call:       MyContract#<unrecognized-selector>
  From:               266
  To:                 1c0

  console.log:
    MyContract: Fallback called


Solution 1:[1]

Upon further investigation I believe metamask is automatically calling the EIP165 "supportsInterface" function.

I added some console.log to my contract and found they matched checks that my contracts supported the ERC721 interface, ERC721 Metadata interface and ERC1155 interface.

It's very annoying and a bit unnerving to these these unhandled calls in my local hardhat development, and I don't fully understand why metamask needs to make them at all.

Solution 2:[2]

The "Hardhat hackathon boilerplate" frontend app defines a periodic check - querying a token balance each second.

Assuming your contract doesn't implement the balanceOf(address) function, the call redirects to the fallback() function.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 T_R_U_T_H
Solution 2 Petr Hejda