1

I want to create a social network app using Solidity, but I am having a hard time thinking of the storage design. Using this link: Are there well-solved and simple storage patterns for Solidity? as a reference, I am thinking that I would have use a "Mapping with Struct", with the followee as the key, and an array of followers as the value. That way if a followee wanted to send a message, it would be simple to just look them up in the struct then iterate over the follower array to send the message.

ex:

 {'123followee':['2345follower','3456follower'],
 '567folowee':['2345follower']}

However, i'm not sure if this makes sense, or if I am missing something else. I am pretty new to both solidity and app development, so wouldn't be surprised if I was.

I figure I could also make a follower:followee struct at the same time to allow a user to easily look up who they are following, but this would open things up to the possibility that the add to the first struct succeeds, while the next one fails. It would also add gas of course.

ex:

{'2345follower': ['123followee', '567folowee'], '3456follower':['123followee']}
walker_4
  • 111
  • 1
  • It will depend on the use case. What queries are you trying to support? Arrays are particularly annoying because they can grow large and operations are linear an that may cause out of gas. – Ismael Aug 10 '22 at 04:28
  • I want to support: adding a follower to a folowee, then sending messages from that followee to their followers. Being able to easily look up who a follower is following would be a good bonus as well. – walker_4 Aug 10 '22 at 07:08
  • I guess the messages wouldn't have to be "sent" neccesarily, but they would need to be able to be accessed by the followers. – walker_4 Aug 10 '22 at 07:14

0 Answers0