Skip to content

Instantly share code, notes, and snippets.

@CosminNechifor
Created January 19, 2019 10:59
Show Gist options
  • Select an option

  • Save CosminNechifor/05d8517c65046803e26fa8f875428293 to your computer and use it in GitHub Desktop.

Select an option

Save CosminNechifor/05d8517c65046803e26fa8f875428293 to your computer and use it in GitHub Desktop.
pragma solidity >= 0.4.22 < 0.6.0;
contract Contract {
string public Name;
constructor(string memory name) public {
Name = name;
}
function getName() public view returns(string memory) {
return Name;
}
}
contract Factory {
Contract[] private contractList;
event ContractCreated(string _name);
function createContract (string memory _name) public {
Contract newContract = new Contract(_name);
contractList.push(newContract);
emit ContractCreated(_name);
}
function getNameById(uint _id) public view returns(string memory){
Contract con = contractList[_id];
return con.getName();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment