Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.