I am just trying this using Remix editor. I am able to call functions from another deployed contract(plain as simple) but when that another deployed contract inherits yet another contract, Now the calling functions from the original contract to the deployed contract doesn't work. I just get a transaction revert
Working Code:
pragma solidity >=0.4.22 <0.6.0;
contract Existing {
Deployed public dc;
constructor(address _deployedContractAddress) public {
dc = Deployed(_deployedContractAddress);
}
function setA(uint _a) public returns (uint) {
return dc.setA(_a);
}
function getA() public view returns (uint) {
return dc.a();
}
}
contract Deployed {
uint public a = 1;
function setA(uint _a) public returns (uint) {
a = _a;
return a;
}
}
Not Working Code:
pragma solidity >=0.4.22 <0.6.0;
contract Existing {
Deployed public dc;
constructor(address _deployedContractAddress) public {
dc = Deployed(_deployedContractAddress);
}
function setA(uint _a) public returns (uint) {
return dc.setA(_a);
}
function getA() public view returns (uint) {
return dc.a();
}
}
contract Ownable {
address public owner;
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
}
contract Deployed is Ownable {
uint public a = 1;
function setA(uint _a) public onlyOwner returns (uint) {
a = _a;
return a;
}
}
So here, the contract Deployed
is inheriting from contract Ownable
and I just get a transaction revert
on calling setA
Note: contract Deployed
is seperately deployed in a separate file and also included in contract Existing
file.