In any language, I would write following:

struct Node {
   void* data;
   Node* next;


head.next = new Node(data, null)

But it seems that solidity doesn't have a concept of pointers.

How could it be done here?

EDIT The answer at the end of Are there well-solved and simple storage patterns for Solidity? is not enough for me as I also need to insert nodes to the middle.

  • (Linked-lists are mentioned at the end of the accepted answer.) Jun 13, 2018 at 17:37
  • I have seen this example, but it doesn't seem to fit to me, because I need to insert in the middle while this code appends only. Jun 13, 2018 at 17:42
  • 1
    My blog has an implementation of a doubly linked list: programtheblockchain.com/posts/2018/03/30/….
    – user19510
    Jun 13, 2018 at 17:42
  • @smarx thank you for the link. It's seems to be a proper approach. Brb when done. Jun 13, 2018 at 18:07
  • 1
    That's the alternative I would have suggested. I'm glad you got it working!
    – user19510
    Jun 13, 2018 at 19:13

1 Answer 1


Here is a library on GitHub which does the trick for circular doubly linked lists. Although I haven't actually used the library, I referenced it heavily when writing my own similar implementation. Even if you don't use it, there's easily enough to work with to make a simple linked list.

Not the answer you're looking for? Browse other questions tagged or ask your own question.