1

This is a continuation of an earlier problem -

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.

However Remix will not compile the parent file giving the following error:

'url notparseableChild.sol'

I have tried changing the Solidity version on all files back to 0.4.18 just to see if this is the problem, however this did not work, so have put back to version ^0.4.21.

Not sure what to do now. Thank you in advance. (Apologies for any formatting errors, am sorting manually).

/browserMyTestToken.sol

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();
   } 
 }

/browserEIP20Interface.sol

pragma solidity ^0.4.21;


contract EIP20Interface {

    uint256 public totalSupply;

    function balanceOf(address _owner) public view returns (uint256 balance);

    function transfer(address _to, uint256 _value) public returns (bool success);

    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);


    function approve(address _spender, uint256 _value) public returns (bool success);


    function allowance(address _owner, address _spender) public view returns (uint256 remaining);

event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}

browser/Child.sol

pragma solidity ^0.4.21;

contract DataItem {
    bytes32 key;
    string value;

    function DataItem(bytes32 k, string v) public {
        key = k;
        value = v;
   }
}
 contract DAppInterface {
    mapping(bytes32 => address) public dataItems;

    function addDataItem(bytes32 k, string v) external {
        dataItems[k] = new DataItem(k, v);
   }
}
2

I just had a similar issue where i was doing the following:

import "MyContract.sol"

While i should have been importing using a relative path:

import "./MyContract.sol" 

I think in your case, Remix doesn't allow importing from "../" if your contract lives on the top directory level.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.