I have two contracts :

contract Child {

      mapping(string => string) private strings;

      function GetString(string key) public constant returns(string value) {
        return strings[key];


contract Parent {

     Child c;

     function GetString(string key) public constant returns(string value) {
         return c.GetString(key);


I got a compilation error :

Return argument type is not implicitly convertible to expected type

I think this is a restriction of solidity that a contract cannot read a variable-sized data that is returned by another contract

Since my string can have more than 32 chars (i cannot use the bytes32 type), how can i achieve that ?

Thanks for your help !


1 Answer 1


For now, it's not possible to pass strings between contracts.

I would consider chopping the string up into two bytes32 chunks. It would be more gas-efficient.

Web3 clients are better suited to pack/unpack/convert. In my opinion, it's usually best to transfer the burden of data type conversion to clients.

Hope it helps.

  • please confirm if this is possible today, post Metropolis Hard Fork
    – 0TTT0
    Mar 3, 2018 at 0:10
  • If I'm not mistaken it's a compiler limitation and it's still true. In practice, I haven't made any variation of the above successfully compile at solc 0.4.20. Possibly someone will chime in if there's a way. Mar 3, 2018 at 0:35

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.