0

I have a fully filled struct ( in memory ), I want to store it ( in storage ), but I can't convert it. I've tested many ways and I got two kinds of errors:

  • copying of type struct of Player memory[] memory to storage not yet supported

  • explicit conversion error

      mapping(uint256 => Match) public matchList;
    
      struct Team {
      Player[] players;
      }
    
      struct Player {
      address username;
      uint256 index;
      uint256 payableInUSD;
      }
    
      struct MatchOption {
      uint256 entry;
      uint256 date;
      uint256 createAt;
      uint256 matchId;
      }
    
      struct Match {
      MatchOption matchOption;
      Team[] teams;
      uint256 price;
      uint256 createAt;
      }
    
     specificMatch   // this is a Match(struct) in memory, I have it fully 
     filled from frontend
    
      Match[] storage copiedMatch= specificMatch;  // THIS DOESN'T WORK
      matchList[0] = copiedMatch;
    

1 Answer 1

0

You can't explicitly fill your new specificMatch array in deployment of the code. Rather, you would have to create a function to fill the new array with the structs you wish to store in it. As a state variable, these would automatically then be stored in storage.

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.