0

Contract A calls contract B.

Does contract A need to know B's full ABI for its external functions? Or can you just give it the interface for the functions that contract A will call.

2

You don't need the full ABI, just the interface for the functions you want to call.

For example, the following code will get the totalSupply of the BAT token without having to know anything except for the address where it resides and the function signature we are calling:

contract ERC20 {
    function totalSupply() constant returns (uint totalSupply);
 }

contract Test {
    address tokenAddress = 0x0D8775F648430679A709E98d2b0Cb6250d2887EF; // BAT TOKEN
    function getTotalSupplyOfToken() public view returns (uint) {
        ERC20 token = ERC20(tokenAddress);

        return token.totalSupply();
    }
}
| improve this answer | |

Your Answer

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

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