Skip to content

Instantly share code, notes, and snippets.

@Juan-cc
Created December 10, 2018 05:22
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 Juan-cc/60627ff4580e16dc99438f599cd20ed9 to your computer and use it in GitHub Desktop.
Save Juan-cc/60627ff4580e16dc99438f599cd20ed9 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&gist=
pragma solidity ^0.4.24;
import "github.com/ConsenSys/Tokens/contracts/eip20/EIP20.sol";
import "github.com/ConsenSys/Tokens/contracts/eip20/EIP20Interface.sol";
import "github.com/ConsenSys/Tokens/contracts/eip20/EIP20Factory.sol";
contract Owned{
address private owner;
constructor() public{
owner = msg.sender;
}
modifier ownerOnly(address _owner){
require(owner == _owner, "Access denied. Company owner only.");
_;
}
function modifyOwner(address _owner)
public
ownerOnly(msg.sender)
{
owner = _owner;
}
}
contract KMP is Owned {
mapping (address => string) public companies;
address private bcFactory;
address private tokenFactory;
constructor() public {
tokenFactory = new EIP20Factory();
bcFactory = new BCFactory();
}
function createBCCompany(string _companyName, string _phone, string _url, string _did, address _uPortAddress)
public
ownerOnly(msg.sender)
returns(address){
BC newCompany = BCFactory(bcFactory).createBCCompany(_companyName, _phone, _url, _did, _uPortAddress);
companies[newCompany] = newCompany.name();
}
function createToken(uint256 _initialAmount, string _name, uint8 _decimals, string _symbol)
public
//ownerOnly(msg.sender)
returns(address){
return EIP20Factory(tokenFactory).createEIP20( _initialAmount, _name, _decimals, _symbol);
}
}
contract BC is Owned {
mapping (address => bool) public admins;
string public name;
string public phone;
string public url;
string private did;
address private uPortAddress;
constructor(string _companyName, string _phone, string _url, string _did, address _uPortAddress)
public
{
name = _companyName;
phone = _phone;
url = _url;
did = _did;
uPortAddress = _uPortAddress;
}
}
contract BCFactory is Owned {
mapping (address => BC) companies;
function createBCCompany(string companyName, string phone, string url, string did, address uPortAddress)
public
ownerOnly(msg.sender)
returns (BC)
{
BC newCompany = new BC(companyName, phone, url, did, uPortAddress);
companies[newCompany] = newCompany;
return newCompany;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment