// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
contract HelloWorld {
uint private simpleInt;
function GetValue() public view returns (uint) {
return simpleInt;
}
function SetValue(uint _value) public {
simpleInt = _value;
}
}
contract Client {
address private obj;
function setObject(address _obj) external {
obj = _obj;
}
// Corrected function to use an existing HelloWorld contract
function UseExistingAddress() public returns (uint) {
// Cast the stored address to the HelloWorld contract
HelloWorld myObj = HelloWorld(obj);
// Call SetValue on the HelloWorld contract
myObj.SetValue(10);
// Return the result of GetValue from the HelloWorld contract
return myObj.GetValue();
}
}
Deploy: