1

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);
 }
}
6
  • Just to clarify, Remix says Child.sol can not be found, or child.sol (note the C or c)? I assume the former and have made the respective edit. Commented Jul 3, 2018 at 17:36
  • 1
    Hello @greenonline thank you for your prompt reply, yes it was the former. That was the first thing I checked as I believed that maybe I had made a typo. However there is a capital 'C' throughout. However now my error is different having logged back in, which is very confusing. It is now saying 'url not parseableChild.sol' in exactly that format. Please just one more thing, when you say you have made the respective edit, do you mean to my original pasted code? Forgive my questions, I am very new to using Stack in this way so might miss some obvious things.
    – Cryptogee
    Commented Jul 5, 2018 at 15:31
  • You can check my edit in the link above my icon, where is says "edited yesterday" Click that. No, I didn't not change the code, that would change the question, and be terribly confusing :-) Suggested code changes should only be made in an answer. I changed only your textual description of the code. Regarding the second matter, if you have a different question (i.e 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 Commented Jul 5, 2018 at 15:41
  • 1
    Thank you @greenonline, I have seen and understood that now. Thanks for your time in cleaning up my question for me. As suggested, I will ask a new question re the new issue.
    – Cryptogee
    Commented Jul 5, 2018 at 15:45
  • No problem. If you have solved this issue, then either mark Maxpeinas answer as the accepted answer (if it helped you) or post your own. It may help others with the same issue. :-) Commented Jul 5, 2018 at 15:47

2 Answers 2

1

If your contracts are not loaded from localhost in Remix and is in "browser" tab, then I think it should point to import "./Child.sol"; as there are no folders in "browser".

../ points to one folder up, so what do you mean that it is two steps away from parent?

1
  • Thank you @maxpeinas for your prompt response and your attempt at helping me. I did indeed use the ./ protocol first, however I was getting errors within my parent file. I then noticed that I had the EIP20Interface.Sol between my parent and Child.sol, so I changed to ../ This made the error in the parent file disappear, however the aforementioned 'cannot find' error popped up in the compiler instead. Now however when I log back in, the error has mysteriously changed to 'url not parseableChild.sol' - So I'm not too sure what is going on here.
    – Cryptogee
    Commented Jul 5, 2018 at 15:38
0

This has now morphed into this problem url not parseable error in Remix Compiler

Please put any answers there, much appreciated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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