Ships.TokenHarvest[][] public nameToCost;

function addNameToCost(Ships.TokenHarvest[][] memory costs) public onlyOwner {
    nameToCost = costs;

The above code gives this error:

Copying of type struct Ships.TokenHarvest memory[] memory to storage not yet supported.

What exactly is the issue here and how can i solve it so that i can assign my input variable to the storage variable?

  • 1
    the "nameToCost" is a storage variable, and your "costs" is in memory. In solidity, you cannot yet copy the array directly from memory into storage. you probably need to iterate over the array and add the items individually. I'm not sure if that is the only error in your code.. working with array and struct is very painful
    – Majd TL
    Sep 10 '21 at 13:16
  • Thanks doing a nested for loop and copying everything over worked
    – cookiekid
    Sep 10 '21 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.