Skip to content

Instantly share code, notes, and snippets.

@CosminNechifor
Created January 21, 2019 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CosminNechifor/9719cbc088fb6a1c8d6615641c1fa374 to your computer and use it in GitHub Desktop.
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?
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