Last active
December 29, 2022 15:07
-
-
Save BellaBe/4abd49706eb86e31d99441184fb86a09 to your computer and use it in GitHub Desktop.
Create Smart contract with already deployed contract
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.13; | |
// usage: contract is already deployed and instantiated, a reference to it is made by using its address | |
contract DeployedDemo{ | |
uint private simpleUint; | |
constructor() payable{} | |
function getValue() public view returns(uint){ | |
return simpleUint; | |
} | |
function setValue(uint _value) public{ | |
simpleUint = _value; | |
} | |
} | |
contract ClientForAlreadyDeployedContract { | |
address contractAddress; | |
function setAddress(address _contractAddress)public{ | |
contractAddress = _contractAddress; | |
} | |
function usePreviouslyDeployedContract() public returns(uint){ | |
DeployedDemo deployedDemo = DeployedDemo(contractAddress); | |
deployedDemo.setValue(10); | |
return deployedDemo.getValue(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment