Skip to content

Instantly share code, notes, and snippets.

@fidsteve
Last active April 12, 2018 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fidsteve/87fdd61996dfa04085161aecbc363690 to your computer and use it in GitHub Desktop.
Save fidsteve/87fdd61996dfa04085161aecbc363690 to your computer and use it in GitHub Desktop.
Cannot create instance in contract because of overloaded constructor - Answer Test Code
pragma solidity ^0.4.17;
contract DynamicContract {
bytes32 public Name;
function DynamicContract (bytes32 name) public {
Name = name;
}
function foo () public view returns (bytes32) {
return (Name);
}
}
contract Factory {
address[] contractList;
function Factory () public {
}
function createContract (bytes32 name) public {
DynamicContract dynamicContractInstance =
new DynamicContract(name);
contractList.push(dynamicContractInstance);
}
function getName(uint ordinal) public view returns (bytes32) {
DynamicContract to_get = DynamicContract(contractList[ordinal]);
// return newContracts[ordinal].Name();
return to_get.foo();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment