Created
June 15, 2023 03:11
-
-
Save AllanJunLi/78e8a4aa8ad68c1a7accea62903e1acc 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.18+commit.87f61d96.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: MIT | |
pragma solidity ^0.8.18; | |
import { SimpleStorage } from "./SimpleStorage.sol"; | |
contract StorageFactory { | |
SimpleStorage[] public listOfSimpleStorageContracts; | |
function createSimpleStorageContract() public { | |
listOfSimpleStorageContracts.push(new SimpleStorage()); | |
} | |
function sfStore(uint256 _simpleStorageIndex, uint256 _newSimpleStorageNumber) public { | |
SimpleStorage mySimpleStorage = listOfSimpleStorageContracts[_simpleStorageIndex]; | |
mySimpleStorage.store(_newSimpleStorageNumber); | |
} | |
function sfGet(uint256 _simpleStorageIndex) public view returns(uint256) { | |
SimpleStorage mySimpleStorage = listOfSimpleStorageContracts[_simpleStorageIndex]; | |
return mySimpleStorage.retrieve(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment