0

I have a contract inheritance in my design and i want to call via web3 a method from the base contract. the oriblem is that i can't know how to do that :

if i do like this :

   contract B {
        uint Bstate;
        function methodX (){
        Bstate =1;
        }
    }

then

import "B.sol"; // because B is in an other file
contract A is B {

}

do i need to manually deploy contract B after deploying contract A and use its abi to call methodX or i can call it directly from the abi of contract A?

2

Inheritance allows us to define a base contract, from which other contracts can use. This allows you to reuse base contracts in future contracts without having to rewrite code.

When contract A inherits from contract B, only contract A is actually deployed to the blockchain. All code from contract B is copied into contract A.

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.