Why can we implement an interface function as mapping property? There's something on doc that explains this behaviour? I couldn't find anything related, but I'm assuming that a mapping property creates something like a function that has the same signature as expected on interface.

Also, there's some reason to do that and not create the function itself? I imagine that we can save some gas but that's it.

pragma solidity >=0.7.0 <0.9.0;

interface ITest {
    function test(address addr) external view returns (address);

contract Test is ITest{
    mapping(address => address) public override test;

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.