0

UPDATE:

struct TotalVotes {
    uint256 value;
}
mapping(uint256 => TotalVotes) public allVotes;

This works, BUT WHY DO I NEED TO use a struct? I only want single value which is an integer? Can't i do it without the struct?

Basically i need to store a dynamic amount of uint256 - which are IDs(unique identifiers).

How do I do this so I could then access numbers for each ID?

for example, i want to get uint256 values for ID, like this

myArray[123] and myArray[9843594]

TLDR: Need to store multiple uint256, that differ by ID which is an uint256. How do I create a mapping for it? An array where values are uint256, but you don't identify it by an address but by ID(uint256?)

I tried doing it like this

uint256 public numberOfVotes;
mapping(uint256 => numberOfVotes) public totalVotes;

but this doesn't work...

5

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.