Created
January 31, 2020 11:01
-
-
Save marsrobertson/71fd6409b20381cc96fc62c74c3775b6 to your computer and use it in GitHub Desktop.
Simple smart contract that creates another in constructor
This file contains 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.5.14; | |
contract Factory { | |
Contract[] newContracts; | |
constructor(bytes32 name) public { | |
createContract(name); | |
} | |
function createContract (bytes32 name) public { | |
Contract newContract = new Contract(name); | |
newContracts.push(newContract); | |
} | |
} | |
contract Contract { | |
bytes32 public Name; | |
constructor (bytes32 name) public { | |
Name = name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment