I have a function that returns a list of BetProposition smart contracts:

function getBetsForMatchup(uint matchupIdentifier) public returns (BetProposition[]) {
        return bets[matchupIdentifier];

Later I initialize a local variable array as such, so I can loop through them:

   BetProposition[] betsToCancel = getBetsForMatchup(matchupIdentifier);

However, this doesn't seem to work and I get this error:

TypeError: Type contract BetProposition[] memory is not implicitly convertible to expected type contract BetProposition[] storage pointer.
    BetProposition[] betsToCancel = getBetsForMatchup(matchupIdentifier);

I'm not totally sure what this means. Any help appreciated. Thanks

1 Answer 1


The compiler thinks you are trying to store the return value of getBetsForMatchup in contract (permanent) storage.

Try changing

   BetProposition[] betsToCancel = getBetsForMatchup(matchupIdentifier);


   BetProposition[] memory betsToCancel = getBetsForMatchup(matchupIdentifier);

This compiled on remix:

   pragma solidity ^0.4.20;
   contract BetProposition {
       uint public somevar;

       function BetProposition(uint _some) public {
         somevar = _some;

   contract Tester2 {
        mapping(uint => BetProposition[]) bets;

        function getBetsForMatchup(uint matchupIdentifier) public view returns (BetProposition[]) {
            return bets[matchupIdentifier];

        function other(uint matchupIdentifier) public view returns(uint) {
             uint total = 0;
             BetProposition[] memory betsToCancel = getBetsForMatchup(matchupIdentifier);
             for (uint i = 0; i < betsToCancel.length; i++) {
                 total = total + betsToCancel[i].somevar();
             return total;
  • Is this a relatively new feature? I get the following error now: UnimplementedFeatureError: Copying of type struct BetCard.Matchup memory[3] memory to storage not yet supported.
    – user339946
    Feb 16, 2018 at 22:43
  • I updated my response with a sample I was able to compile on remix. Note, this is using solidity ^0.4.20. Also, if you are trying to call getBetsForMatchup externally (ie from javascript) you will run into trouble as functions returning contract types isn't supported via the abi.
    – Howard
    Feb 16, 2018 at 23:08
  • @Howard, is that where "pragma experimental ABIEncoderV2" comes in? You get warned not to use it in production, but it's worth a try depending on how it's being used. Feb 16, 2018 at 23:12
  • That pragma works for returning structs, not sure about contracts refs. Its certainly useful, so long as you are in full control of your client.
    – Howard
    Feb 17, 2018 at 4:00

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.