I am trying to create a scenario whereby a user can create a child token from the main contract (and then later on a (grand[?])child coin from that token).
I have looked up various documentation and Q&As and have cobbled together the code below. My problem is Remix will not compile the parent contract, saying that Child.sol
cannot be found, even though it is two steps away from the parent. I'm fairly sure the problem is within the Child.sol
contract as I've just copied and pasted the information.
pragma solidity ^0.4.21;
import "./EIP20Interface.sol";
import "../Child.sol";
contract MyTestToken is EIP20Interface {
uint256 constant private MAX_UINT256 = 2**256 - 1;
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowed;
string public name;
uint8 public decimals;
string public symbol;
function MyTestToken(
uint256 _initialAmount,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol
) public {
balances[msg.sender] = _initialAmount;
totalSupply = _initialAmount;
name = _tokenName;
decimals = _decimalUnits;
symbol = _tokenSymbol;
}
function transfer(address _to, uint256 _value) public returns (bool success) {
require(balances[msg.sender] >= _value);
balances[msg.sender] -= _value;
balances[_to] += _value;
emit Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
uint256 allowance = allowed[_from][msg.sender];
require(balances[_from] >= _value && allowance >= _value);
balances[_to] += _value;
balances[_from] -= _value;
if (allowance < MAX_UINT256) {
allowed[_from][msg.sender] -= _value;
}
emit Transfer(_from, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
function approve(address _spender, uint256 _value) public returns (bool success) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
mapping(bytes32 => Child) childList;
function spawnChild(bytes32 childId) {
Child current = new Child();
childList[childId] = current;
}
function callChildFunction(bytes32 childId) {
childList[childId].theChildfunction();
}
}
pragma solidity ^0.4.21;
contract DataItem {
bytes32 key;
string value;
function DataItem(bytes32 k, string v) {
key = k;
value = v;
}
}
contract DAppInterface {
mapping(bytes32 => address) public dataItems;
function addDataItem(bytes32 k, string v) external {
dataItems[k] = new DataItem(k, v);
}
}
Child.sol
can not be found, orchild.sol
(note theC
orc
)? I assume the former and have made the respective edit.url not parseableChild.sol
) then you should ask a new question, using the link above. You can't have two questions in one post. You can refer back to this issue, if you need to, (using this question's URL) in the new question. HTH