Guest User

Untitled

a guest
Jan 19th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. pragma solidity >= 0.4.22 < 0.6.0;
  2.  
  3. contract Contract {
  4. string public Name;
  5.  
  6. constructor(string memory name) public {
  7. Name = name;
  8. }
  9.  
  10. function getName() public view returns(string memory) {
  11. return Name;
  12. }
  13. }
  14.  
  15. contract Factory {
  16.  
  17. Contract[] private contractList;
  18.  
  19. event ContractCreated(string _name);
  20.  
  21. function createContract (string memory _name) public {
  22. Contract newContract = new Contract(_name);
  23. contractList.push(newContract);
  24. emit ContractCreated(_name);
  25. }
  26.  
  27. function getNameById(uint _id) public view returns(string memory){
  28. Contract con = contractList[_id];
  29. return con.getName();
  30. }
  31. }
Add Comment
Please, Sign In to add comment