0

e.g. "ABC" contract will use "XYZ" properties and methods Both contract owner is same.

Thanks

0

Try this code in Remix:

pragma solidity 0.4.24;

contract XYZ {
    address public owner;

    constructor() public {
        owner = msg.sender;
    }

    function doSomething() external {
        emit SomethingDone(address(this));
    }

    event SomethingDone(address _addr);
}

contract ABC {
    address public owner;

    XYZ xyz_;

    constructor(XYZ _xyz) public {
        xyz_ = _xyz;
        owner = msg.sender;
    }

    function interactWithXYZ() external {
        xyz_.doSomething();
    }
}

First, deploy contract XYZ. Then, deploy contract ABC using the address of the deployed XYZ contract. When that's done, try calling ABC 's interactWithXYZ() method. You'll see an event in the console.

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.