Anyone get an error when using inheritance?

Hello everyone. I noticed an issue with inheritance when working on the betting dapp project. I decided to reuse the Ownable contract from People project and made a copy of it in my betting dapp directory. I set is as the parent of my betting dapp such as “contract Coinflip is Ownable”. However, whenever i use this inheritance, there seems to be an error. After compiling the contract and deploying, I go to to the Ganache interface and when I click on the the Coinflip contract under “contracts” tab. The storage/transaction section is empty. Also there is a note saying “There was an issue decoding your contract. please open an issue on github etc.”.

I looked long and hard why this was happening, and only after removing the parent “Ownable” from the contract did everything work again properly. Does anyone else have a similar issue?

This is the code of the Ownable contract that I use

pragma solidity 0.5.12;

contract Ownable {

    address public contractOwner;

//** Constructor Section */
    constructor() public{
        contractOwner = msg.sender;
//** Modifier Section */
// Only Owner of the Contract can execute the function modifier
    modifier onlyContractOwner() {
        require(msg.sender == contractOwner, "You are not entitled to execute this function.");
//** Setter Function Section */
    function transferOwnership(address newOwner) public onlyContractOwner {
        require(newOwner != address(0));
        contractOwner = newOwner;

I hope to be helpful.

1 Like