1

Is there anyway to know the name of the external method calling a contract's method from within the called contract method?

As an example, msg.sender gives you the address of the calling contract. I tried using msg.sig, however msg.sig gives you the function of the contract being called and not the name of the function where the original call came from.

In my particular application, I do not have control of the calling contract so I cant have a solution on that end.

Method A From Contract A calls Method B From Contract B.

Contract B needs to know what method from Contract A Called without Contract A passing that information.

Is this possible?

1
  • Do you have ABI from the contract you want to interact with ? Every methods are written there.
    – GrindCode
    Jul 1, 2021 at 21:36

1 Answer 1

1

Is there anyway to know the name of the external method calling a contract's method from within the called contract method?

EVM or Solidity do not pass such information, so this is impossible.

Contract B needs to know what method from Contract A Called without Contract A passing that information.

Redesign your application.

2
  • Mikko, I have the same issue, but I only need to know that calling SmartContract address (as security validation). Can you share what would be the best-practice approach to the redesign? I have a core contract that has all the arrays, and another contract that need to retrieve, massage and store them back. So, the core storage contract need to be sure that the request is coming from a trusted source. Thank you
    – jlee88my
    Jun 27, 2022 at 10:44
  • msg.sender is the calling address Jun 27, 2022 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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