1

Here is my code example:

pragma solidity ^0.5.16;
pragma experimental ABIEncoderV2;

contract Operations {

    Operation[] public operations;

    struct Operation {
        uint startOperation;
        uint endOperation;
        string responsible; 
        string opType;
    }

    function getAllOperations() public view returns(Operation[] memory){
        return operations;
    }
}

I have 3 questions:

1 - Why do I need pragma experimentals ABI to return an Array of structs?

2 - Why do I have a warning saying I shouldn't use experimental features in live deployments?

3 - Is there any other way of doing this without using an experimental feature?

2

1 - Check this for more detailed info

2 - If you switch the pragma solidity 0.5.X to 0.6.2 (last one), you will see that you are able to deploy the same contract with no warning saying "you shouldn't deploy the experimental features in live networks".

3- Not for now, if you use solc bellow 0.6.X, the only way of retrieving the values by key/index

Hope this helps

|improve this answer|||||
1

Yes - use Solidity 0.6.x where the ABIEncoderV2 is no longer considered experimental ;). They've been working on it for a while, and it's been available to test in earlier versions during this period.

Having said that, you still need to use a pragma to enable it in 0.6, but hopefully it all works now!

|improve this answer|||||

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.