Understanding Dynamic Arrays and Memory in Solidity

Поделиться
HTML-код
  • Опубликовано: 27 сен 2024

Комментарии • 36

  • @pulsechainalltheway1845
    @pulsechainalltheway1845 5 месяцев назад +1

    Your videos on solidity storage are amazing👍👍👍👍👍👍

    • @cryptojesperk
      @cryptojesperk  5 месяцев назад

      Thank you so much 🙏 appreciate it

  • @edmundobarbieri2214
    @edmundobarbieri2214 Год назад +1

    Gm! Very happy to see that there's a new video this morning. Thanks.

  • @AbhaySingh-wf9nk
    @AbhaySingh-wf9nk Год назад +1

    What a lesson you have taught me, it was a lot of fun.

  • @aluranarveez9021
    @aluranarveez9021 11 месяцев назад +1

    GOlD IS HERE. THANK YOU a LOT

  • @xabieroterino
    @xabieroterino Год назад +1

    Easy and clear , great video!

  • @surajsingh-dq4ul
    @surajsingh-dq4ul 10 месяцев назад +1

    Thank you Jesper for such a detailed and well explained video. But i have one question related to array of structs. So i can get the values of first struct in the array but for the other structs in array how you will find the location for other structs to find its values. Please keep posting these advance videos.

    • @cryptojesperk
      @cryptojesperk  10 месяцев назад

      Great question. The structs will be laid out consecutively when creating a dynamic array of structs. I wrote some code for you here to try it yourself: gist.github.com/jesperkristensen58/50d1b67089ad80e6d6ae8fb6b2212a55
      ---- Instructions:
      // Call pushToArray with, e.g.: (John,4), then (ben,2)
      // then call h = hashNumber(0)
      // then take that output and call getStorageAt(h)
      // then look at getStorageAt(h+1) = john; getStorageAt(h+2) = 4; getStorageAt(h+3) = ben; getStorageAt(h+4) = 2
      This confirms the layout pattern. Let me know if you have any additional questions.

    • @surajsingh-dq4ul
      @surajsingh-dq4ul 10 месяцев назад +1

      Thank you Jesper for quick reply and the solution. 👌👌

    • @cryptojesperk
      @cryptojesperk  10 месяцев назад

      @@surajsingh-dq4ul thanks for watching and I'm thrilled to learn that you, in turn, found it useful 🙏

  • @loserdavictor
    @loserdavictor Год назад +1

    best video ser🐧🐧

    • @cryptojesperk
      @cryptojesperk  Год назад +1

      Thank you very much for watching! 🙏

  • @codeWithBala
    @codeWithBala Год назад +1

    Helllo sir , please post videos waiting for your video - two months !

    • @cryptojesperk
      @cryptojesperk  Год назад

      That is kind of you! And absolutely agree - I do apologize. I recorded a much longer video than usual and the team is backed up right now - the new video is coming out shortly! 🙏 thank you for the support

    • @codeWithBala
      @codeWithBala Год назад +1

      @@cryptojesperk thankyou sir! Excited to see the new video 😀

  • @noname13345
    @noname13345 11 месяцев назад +1

    awesome visualization stuff, pure gold!!!!
    in a nutshell, one should rely on memory as little as possible right?

    • @cryptojesperk
      @cryptojesperk  11 месяцев назад +1

      Thank you 🙏 well it certainly depends. Storage costs a lot more than memory in general; using the stack over putting things in memory will also generally make more sense, but sometimes you have to use memory of course and many times it definitely makes sense to use. The quadratic cost also doesn't kick in for a while; so don't be scared of using it. Just be aware of the cost and whether you're on the cubic part of the cost curve.

  • @lol-rl6uu
    @lol-rl6uu 6 месяцев назад +1

    Thanks for making the video, just some feedback though because I know a lot of work goes into making these videos, but the moving avatar in the video is pretty annoying. It covers the entire code that you're trying to explain. We can pause the video and go onto Github but it seems to really defeat the purpose of having something in video format in the first place. Anyways, thanks for uploading.

    • @cryptojesperk
      @cryptojesperk  6 месяцев назад

      thank you very much for watching and for this feedback! I will be more careful with where I put the avatar -- I def don't want to cover up the content on the screen so this is very helpful! 🙏

  • @RahulChauhan-gn2px
    @RahulChauhan-gn2px Год назад +1

    great video..

  • @ununbrian
    @ununbrian Год назад +1

    good content but your vid is too jumpy that makes me lost focus when i tryin to read your code

    • @cryptojesperk
      @cryptojesperk  Год назад +1

      thanks for the feedback! I offer a link to the actual source code that you can check out or open side-by-side. Do you mean that I should not jump between the code and the drawing program? For example, stay in the code entirely? Does pausing the video help read the code?

    • @ununbrian
      @ununbrian Год назад +1

      @@cryptojesperk yes! avoid the unnecessary zoom and moving avator can help reading the content and thinking about the explaination as well👍🏼 Please keep update your video!

  • @loserdavictor
    @loserdavictor Год назад +1

    why are we multiplying the bucket(slot) with 32 (0x20) while trying to access the slot?
    can you please write few lines and explain that part please🐧🐧

    • @cryptojesperk
      @cryptojesperk  Год назад +2

      I wanted to make an analogy to the "storage buckets," and memory is laid out like 32-byte words/buckets. When using "mload(...)" the input parameter is the offset in bytes (not buckets). So "mload(4)" will read 32 bytes *starting at byte 4*. If we want to read bucket/chunk 4 instead (my drawings talked about buckets/words/chunks) we need to offset by 32 bytes multiplied by 4 (since each bucket takes up 32 bytes). So we do: "mload(mul(4, 0x20))". The "bucket analogy" is more for visual reasons and that words are indeed 32 bytes and are laid out next to each other, so I like to think about it this way, but there's nothing "special" about a bucket (no particular boundaries).

    • @loserdavictor
      @loserdavictor Год назад +1

      @@cryptojesperk i understand it better now, because storage reads uses slots to read and memory reads using bytes - this part got a little confusing for me
      thanks for taking time to explain ser🐧🐧

    • @cryptojesperk
      @cryptojesperk  Год назад +1

      @@loserdavictor Of course! Great question. Let me know if you have additional questions - I think this is also helpful to others seeing this :-) Thanks! 🤝

  • @bitedeep4876
    @bitedeep4876 Год назад +1

    Finally! I found a good explanation for this

    • @cryptojesperk
      @cryptojesperk  Год назад

      Thank you very much -- I'm thrilled that you found it helpful 🙏

  • @FelipeNovaesRocha
    @FelipeNovaesRocha Год назад +1

    Amazing content Jesper! Really awesome! Only thing will suggest its remove the music background or lower the volume after some time that drain the attention. I think that its about the 20min diversion attention.
    But keep the good work!! Help me alot!

    • @cryptojesperk
      @cryptojesperk  Год назад +1

      That's great feedback, thank you! Thanks for watching and I am glad it helped! Look out for an updated music format in future videos 🙂