Skip to content

Instantly share code, notes, and snippets.

@CosminNechifor
Last active January 21, 2019 19:48
Show Gist options
  • Save CosminNechifor/5f16970da30df2b48f5a040fbbef7c9c to your computer and use it in GitHub Desktop.
Save CosminNechifor/5f16970da30df2b48f5a040fbbef7c9c to your computer and use it in GitHub Desktop.
pragma solidity >= 0.4.22 < 0.6.0;
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