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:
Parent
has been deployed separately to address 0x123456
and its property number
now has value of 5
.Parent
's (on address 0x123456
) property number
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.