Skip to content

Instantly share code, notes, and snippets.

@amkurian
Created March 29, 2022 14:37
Show Gist options
  • Save amkurian/49d506346245190a155d20b125648795 to your computer and use it in GitHub Desktop.
Save amkurian/49d506346245190a155d20b125648795 to your computer and use it in GitHub Desktop.
StorageFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "./SimpleStorage.sol";
contract StorageFactory is SimpleStorage{
SimpleStorage[] public simpleStorageArray;
function createSimpleStorageContract() public {
SimpleStorage simpleStorage = new SimpleStorage();
simpleStorageArray.push(simpleStorage);
}
function sfStore(uint256 _simpleStorageIndex, uint256 _simpleStorageNumber) public {
SimpleStorage(address(simpleStorageArray[_simpleStorageIndex])).store(_simpleStorageNumber);
}
function sfGet(uint256 _simpleStorageIndex) public view returns(uint256) {
return SimpleStorage(address(simpleStorageArray[_simpleStorageIndex])).retrieve();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment