3

Inside my contract I want to use importkeyword to load other contracts and libraries to make my code more clean. As an example, I carried DateTime.sol contract to another file and import it inside myContract file without any problem.

myContract.sol:

import "/Users/avatar/populus/contracts/DateTime.sol"; //works.
contract myContract{
   DateTime date = new DateTime(); //does not work.
   <Some_Code>
}

But from myContract contract, when I try to call the DateTime contract as: DateTime date = new DateTime() I have faced with the following error:

/usr/local/lib/python2.7/site-packages/populus/chain.py:580: in get_contract
    if contract_name not in self.contract_factories:
/usr/local/lib/python2.7/site-packages/populus/utils/functional.py:50: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
/usr/local/lib/python2.7/site-packages/populus/chain.py:198: in contract_factories
    compiled_contracts = self.project.compiled_contracts
/usr/local/lib/python2.7/site-packages/populus/project.py:153: in compiled_contracts
    optimize=True,
/usr/local/lib/python2.7/site-packages/populus/compilation.py:42: in compile_project_contracts
    compiled_sources = compile_files(contract_source_paths, **compiler_kwargs)
/usr/local/lib/python2.7/site-packages/solc/main.py:129: in compile_files
    **kwargs
/usr/local/lib/python2.7/site-packages/solc/utils/string.py:91: in inner
    return force_obj_to_text(fn(*args, **kwargs))

E Dynamic exception type: boost::exception_detail::clone_impl<dev::solidity::InternalCompilerError>
E std::exception::what: std::exception
E [dev::tag_comment*] = Compiled contract not found.

But when the DateTime contract was embedded inside myContract.sol file, I was able to call DateTime date = new DateTime(); from myContract contract without having any problem. I have used following approach: How to call a Contract from an existing contract approach.

myContract.sol:

contract myContract{
   DateTime date = new DateTime(); //works now.
   <Some_Code>
}
contract DateTime{
   <Some_Code>
}

[Q] I have tried this approach on Solidity Browser and it works. How could I fix this problem on Populus?

Some information:

  • platform darwin -- Python 2.7.12, pytest-3.0.2, py-1.4.31,
    pluggy-0.3.1
  • plugins: populus-1.1.0
  • OS: Mac OS X

solc --version: the solidity compiler commandline interface Version: 0.4.8+commit.60cc1668.Darwin.appleclang

Thank you for your time and help.

3

The error you have is not related to Populus:

   Dynamic exception type: boost::exception_detail::clone_impl<dev::solidity::InternalCompilerError>
   E std::exception::what: std::exception

It says Solidity cannot compile your contract because of a bug. Please repeat the issue by manually compiling the contracts from the command line and then issuing a bug report against Solidity with repeatable steps.

Also, update your Solidity to the latest version before doing this.

  • I am using latest version of solc, but still I am facing with the same problem. I cannot also import library.sol files as well. – alper Jan 20 '17 at 11:23
  • I suggest you do compiling by hand and if that still fails repot a bug as instructed. – Mikko Ohtamaa Jan 20 '17 at 11:36

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.