0

I thought it is required to call token contract's functions to use transfer or transferfrom when I define new contract. But if the contract inherits or imports token contract, then call is not required anymore right? Please correct me. And let me know difference between inherit and import. Thank you!

  • "inherits or imports" - two different answer, one for each case. – goodvibration May 30 '19 at 15:38
0

If your contract inherit from Base contract then you can use function from the base contract that are marked as public or internal without a call. But external functions will use call regardless.

contract Base {
    function foo() external returns (uint) {
        return 1234;
    }
    function bar() internal returns (uint) {
        return 1234;
    }
    function baz() public returns (uint) {
        return 1234;
    }
}

If you inherit like this

contract A is Base {
    function test() public returns (uint, uint, uint) {
        // solidity 0.4 allows this
        // uint a = foo();
        // with solidity 0.5 you have to explicitely use 'this.'
        uint a = this.foo();   // external use call
        uint b = bar();        // do not use call
        uint c = baz();        // do not use call
        return (a, b, c);
    }
}
| improve this answer | |

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