New answers tagged

0

To get the value of a private mapping you need to access it from getter function within the contract. - That OOP point of view. In Ethereum, since Everything is public - anyone can read that mapping if they know the contract address and the ABI related to it or may be you can decompile the bytecode stored on that contract address.


0

You are not allowed to pass structs (or an array of structs in your case). Instead of passing an array of Review elements, pass several arrays - one for each field in this struct. Then construct a Review instance before pushing it to reviewsMap[author]. I recommend asserting that the lengths of the arrays are identical.


1

This looks like two or more questions, to me. A high-level question is the overall data layout. I'm not convinced this layout is ideal. It is usually best to think about readability and simplicity first and optimize later. With that in mind, I would probably tackle it with this: https://github.com/rob-Hitchens/UnorderedKeySet/blob/master/contracts/...


3

The pattern you are using is valid for certain table-like sets, but you should be aware of the limitations. It is ill-advised to do anything with a contract that loops - Getting Loopy with Solidity. You can, however, make it possible for a client to loop. It should be understood that "client" is an off-chain entity, in this context, because if it wasn't ...


4

Trust me. Everytime (everytime!) you are thinking to loop trough a dataset whose dimensions you cannot predict at the “start of the time“ in a blockchain based system, you are using blockchain for the wrong thing and/or your algorithm must be changed by rethinking it. Your model should be something where if a new “user” is added, the simply operation to add ...


Top 50 recent answers are included