Last active
January 9, 2025 07:23
-
-
Save nakajo2011/6f4a0fe380e84ecc353d8deeb4782077 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.26+commit.8a97fa7a.js&optimize=false&runs=200&gist=
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: GPL-3.0 | |
pragma solidity >=0.8.2 <0.9.0; | |
contract Storage { | |
uint256 number; | |
function store(uint256 num) public { | |
number = num; | |
} | |
function retrieve() public view returns (uint256){ | |
return number; | |
} | |
} | |
contract Caller { | |
Storage storageContract; | |
uint256 copied; | |
constructor(address storage_addr) { | |
storageContract = Storage(storage_addr); | |
} | |
function copyFrom() public { | |
copied = storageContract.retrieve(); | |
} | |
function getCopyNum() public view returns(uint) { | |
return copied; | |
} | |
function getNumAt(address storage_addr) public view returns(uint) { | |
Storage s = Storage(storage_addr); | |
return s.retrieve(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment