0
votes

I have the following Solidity contract:

pragma solidity ^0.7.4;

contract Parent
{
    uint public number;
}

contract Child is Parent
{
    function setParentNumber(uint _number) public {
        number = _number;
    }
}

So when I deploy Child, I'm able to modify the Parent's property number. So far so good.

Question: Is is possible to extend an already deployed contract and access its public properties?

Example:

  1. Parent has been deployed separately to address 0x123456 and its property number now has value of 5.
  2. Now I want to deploy Child to a separate address, but I want to be able to set the Parent's (on address 0x123456) property number
1

1 Answers

1
votes

If the contract (Parent) does not provide interfaces to mutate its data, other contracts cannot do it.

Otherwise modifying balances of accounts would be free game for everyone.