Having issues initialising a variable length storage struct, can anyone explain what I'm doing wrong please?
struct Example {
uint8[2] eg;
bool[2] ex;
address someAddress;
string myString;
}
Example[] internal examples;
function addExample(Example[] memory _examples) external {
for (uint256 i; i < _examples.length; i++)
examples.push(_examples[i]);
if (_examples.length > 0)
examples[0].eg[1] = 9; //ERROR HERE
}
Jan 16, 2022, 11:07 PM
use pragma experimental ABIEncoderV2; in header file
function addExample(Example[] memory _examples) external {
Jan 16, 2022, 11:10 PM
Yeah sorry, that's a typo from simplifying, that's there else the compiler complains
Jan 16, 2022, 11:11 PM
Ok, one moment i look more deeply
Jan 16, 2022, 11:12 PM
I'll check this - I'm using it in my base contract, but the error occurs in an inherited contract which doesn't have this in the header so I'll add and make sure this isn't the issue. I think I can use pragma abicoder v2 now as it's no longer experimental
Although checking the docs, given I'm using 0.8.11 I shouldn't need it at all
Jan 16, 2022, 11:17 PM
sorry, now i using the sol version of 0.6.12 in my proj ))
How create this strcut in remix Example[] memory _examples ?)
Jan 16, 2022, 11:21 PM
[[[0,1],[false,true],"0x0000000000000000000000000000000000000000","someString"]]
Jan 16, 2022, 11:23 PM
It is look fine 🤔
Jan 16, 2022, 11:44 PM
Hmmmmmmm, thanks for doing this. There must be something weird going on in my set-up. TIL you can use console.log in remix as well, so that was helpful!
Jan 17, 2022, 12:09 AM
Also, you can use 'console.log()' in remix
I'm glad help you
What do you develop?
I'm glad help you
What do you develop?
Which function using only for selling erc20 token ?
- Is func transferFrom() ?
- Is func transferFrom() ?
Jan 17, 2022, 1:51 AM