Skip to content

Instantly share code, notes, and snippets.

@marsrobertson
Created January 31, 2020 11:01
Show Gist options
  • Save marsrobertson/71fd6409b20381cc96fc62c74c3775b6 to your computer and use it in GitHub Desktop.
Save marsrobertson/71fd6409b20381cc96fc62c74c3775b6 to your computer and use it in GitHub Desktop.
Simple smart contract that creates another in constructor
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