Created
January 21, 2019 19:47
-
-
Save CosminNechifor/9719cbc088fb6a1c8d6615641c1fa374 to your computer and use it in GitHub Desktop.
Is this a good approach to reduce the bytecode of the B 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
contract A { | |
uint256 value; | |
constructor(uint256 _value) public { | |
value = _value; | |
} | |
function getValue() external view returns(uint256) { | |
return value; | |
} | |
} | |
interface IA { | |
function getValue() external view returns(uint256); | |
} | |
contract FactoryA { | |
A[] private contractList; | |
function createContractA(uint256 _value) external { | |
A a = new A(_value); | |
contractList.push(a); | |
} | |
function getContractListAddresses() external view returns (A[] memory) { | |
return contractList; | |
} | |
} | |
interface IFactoryA { | |
function createContractA(uint256 _value) external; | |
function getContractListAddresses() external view returns (A[] memory); | |
} | |
contract B { | |
event newContractACreated(uint256 _value); | |
IFactoryA factoryContract; | |
constructor(address _factoryContractAddress) public { | |
factoryContract = IFactoryA(_factoryContractAddress); | |
} | |
function createContractA(uint256 _value) public { | |
factoryContract.createContractA(_value); | |
emit newContractACreated(_value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment