Look at this basic Solidity contract:
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;
contract MyContract {
string[] public tmp;
...
function read_tmp() public view returns(string[] memory){
return tmp;
}
}
I have create a scaffolded truffle react project.
First, i get an error when trying to deploy this contract with this command:
truffle migrate --network ropsten --reset
The error is:
TypeError: This type is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature.
This error is due to string[] return type of read_tmp. I am not happy do to that but i have add this line at the top of my contract and the deploy works now:
pragma experimental ABIEncoderV2;
My first question is: Why should i enable experimental features ? My 0.6.11 compiler version should allow this feature natively...
My second question is i have tried this in App.js file:
await this.state.contract.methods.tmp().call();
Solidity should create automatically a getter called tmp() for tmp public field.
I do not understand why but i have this javascript error in my browser:
Uncaught (in promise) Error: Invalid number of parameters for "tmp". Got 0 expected 1!
Everything works if i call read_tmp(). So my question is why tmp() needs an argument ? (i have tried to pass an integer but it does not work)
Thanks a lot
My 0.6.11 compiler version should allow this feature natively...
- no, it shouldn't (what makes you think it should?).