Created
January 19, 2019 10:59
-
-
Save CosminNechifor/05d8517c65046803e26fa8f875428293 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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