pragma solidity ^0.4.24;
/// 通过合约Controller创建合约、记录众多合约实例地址
/// 管理合约,用于统一创建、记录核心合约
contract Controller {
address[] public projects;
/// createProject() 通过 new Core(...)创建合约实例
function createProject(string _str, uint256 _initialS) public {
address newProject = new Core(_str,_initialS);
projects.push(newProject);
}
/// getProjects() 得到众多合约地址,
function getProjects() public view returns(address[]) {
return projects;
}
}
/// 主合约,完成主要业务逻辑
contract Core {
address public owner;
string public description;
uint256 public initialSupply;
constructor(string _str, uint256 _initialSupply) public {
owner = msg.sender;
description = _str;
initialSupply = _initialSupply;
}
}
本文来自链客区块链问答社区https://www.liankexing.com/index.php/Home/Note/note_page.html?id=299
网友评论