Hello there! I need help for initializing in contract global scope array of arrays of structs. I'm trying make it that:

struct User {
uint balance;
}

User[] Matrix;

Matrix[8] Box;

but got compiler error:
TypeError: Name has to refer to a struct, enum or contract.

May 21, 2022, 3:42 PM
What is the problem? It is possible?
May 21, 2022, 3:44 PM
You dont have Matrix struct
May 21, 2022, 3:44 PM
But I have: User[] Matrix; - it's wrong?
May 21, 2022, 3:45 PM
Matrix is not a type in solidity
How did you get your icon image
May 21, 2022, 3:46 PM
Please help! How i can init variable that is array (8 - length) of arrays of structs?
Just occasionally somewhere found in Internet
May 21, 2022, 3:47 PM
User[][8] Matrix;
Two dimension Array
May 21, 2022, 3:48 PM
Thank you very much!!!
Good luck1
Hello again! Please help! If I have a structure:

struct User {
address wallet;
uint balance;
}
User[][8] Box;

How I can return the user from method by his wallet (type - address)? It's possible?
May 21, 2022, 4:06 PM
mapping are good friends
@Katerina_978 loves to do struct in a mapping in a mapping
👀
May 21, 2022, 4:08 PM
Ok, thanks
I understood
Is that?
struct User {
uint balance;
}

mapping(address => User) Matrix;

Matrix[8] Box;
May 21, 2022, 4:11 PM
Matrix is a variable name. It cant be used as a type
If you say uint256 Box; . you cant declare Box myBox;
Box isnt a type now. You should return to a tutorial, these are foundational education
May 21, 2022, 4:16 PM
Is that ok?

mapping(address => User)[8] Box;
May 21, 2022, 4:21 PM
can you explain why you need that 8 ?
who are you?
why?
May 21, 2022, 4:24 PM
It's specification - need 8 matrices
That's all
May 21, 2022, 4:30 PM
so 2 dimensions array?
with which size?
May 21, 2022, 4:31 PM
But I need saving balance and find each user balance by his wallet
Need 8 matrices, each should have unbounded map address => balance (but in the future will added more props to user
May 21, 2022, 4:32 PM
I can't understand you
May 21, 2022, 4:32 PM
So, map address => user(balance and some props)
May 21, 2022, 4:32 PM
then justy do a mapping
from address
to a struct
forget the "8"
May 21, 2022, 4:33 PM
sorry, my English is bad
It's no matters that array 8 or unlimited (from point of view gas expenses)?
May 21, 2022, 4:34 PM
If you don't explain what you need to do is not easy to tell
you should give info about what you are trying to achieve
May 21, 2022, 4:35 PM
It's pyramid that has 8 levels
May 21, 2022, 4:35 PM
a ponzi?
May 21, 2022, 4:35 PM
From first level user going to second and so forth, 8 - it's maximum
May 21, 2022, 4:35 PM
.
referral scheme?
May 21, 2022, 4:36 PM
Yes... 😳
May 21, 2022, 4:36 PM
and why you are doing this?
May 21, 2022, 4:36 PM

© 2024 Draquery.com All rights reserved.