Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
- }
- }
Add Comment
Please, Sign In to add comment