0

Suppose I have an inheritance contract (xyz.sol) with three contracts A, B and C such that C is B, I am trying to compile using solc offline in node console. Upon compiling, I have three separate bytecodes and ABI interface generated. For a single contract alone ABI=..... [`:xyz'].interface used to give the ABI alone. Now because there are more ABI present in the output compiled code, it returns an error (undefined). Is it possible to get all the ABI interface together or separate by any indexing method?

0

I don't understand this statement:

Now because there are more ABI present in the output compiled code, it returns an error (undefined).

I'm not 100% sure "what" exactly returns the error. Depends on what you're doing, I suppose. You should probably only be concerned with the ABI for the contract you want to deploy.

There's an ABI for each contract and it's possible you want to deploy any of the contracts contained in your source. You'll find that B's functions are part of C's ABI.

Consider this even simpler example:

pragma solidity 0.4.18;

contract A {

    function aDo() public pure returns(bool success) {
        return true;
    }
}

contract B is A {

    function bDo() public pure returns(bool success) {
        return true;
    }

}

Notice that the ABI for B contains function aDo() because B is A.

[{"constant":true,"inputs":[],"name":"bDo","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"aDo","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"pure","type":"function"}]

The compiler is going to give you the ABI for A, but the thing is you don't really need it (or the bytecode for A) unless you plan to deploy A, and you probably don't want to.

In most use-cases, you would only want to deploy the main contract that has inherited the lessor components.

Hope it helps.

p.s. If using Truffle, they take/make the assumption that the source file name matches the name of the contract you will be interested in deploying (B in my example, C in yours), although the source and imports may load it up with many contracts that won't be deployed by themselves.

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.