Solidity Tutorial: Mappings (simple mappings, nested mappings, array in mappings...)

Поділитися
Вставка
  • Опубліковано 5 жов 2024

КОМЕНТАРІ • 39

  • @oleksandrkireiev7628
    @oleksandrkireiev7628 2 роки тому +2

    Tricky thing is that if we do delete scores[msg.sender][0] array element with index 0 is not being deleted and array shifted left (as might be expected) - it's just getting value of 0
    mapping(address => uint[]) public scores;
    function deleteScore() external {
    scores[msg.sender].push(10);
    scores[msg.sender].push(15);
    scores[msg.sender].push(20);
    delete scores[msg.sender][0];
    }
    Result : uint256[] : score 0,15,20

  • @andreamarrocco7125
    @andreamarrocco7125 3 роки тому +2

    OMG you saved me! Literally saved me. I was implementing a Dapp and couldn't understand the mapping in solidity.... More and more stack overflow question, sites, forum.... And then you. Thank you so much bro! 🙏🏻🙏🏻🙏🏻🙏🏻

    • @EatTheBlocks
      @EatTheBlocks  3 роки тому +1

      Great to hear!

    • @liotr6737
      @liotr6737 3 роки тому +1

      It's very reassuring that our dapp developers who launch smart-contract don't even understand basic type of their langage lol

    • @andreamarrocco7125
      @andreamarrocco7125 3 роки тому

      @@liotr6737 this was a university project Lionel, we had to learn solidity and developed a Dapp in just two months... With other 3 different courses in parallel 😉

  • @johnmark-ps8jy
    @johnmark-ps8jy 4 роки тому +4

    I like your work, keep it up and please point me to a complete project end to end if you have any

    • @EatTheBlocks
      @EatTheBlocks  4 роки тому

      thanks, you can checkout this full tutorial here:
      ua-cam.com/video/8wMKq7HvbKw/v-deo.html

  • @diegohiroshiysusvideos2909
    @diegohiroshiysusvideos2909 2 роки тому

    Thank you very much for the tutorial, I did need to learn about from Mapping and this video I help me. Regards from Argentina.

  • @petcha73
    @petcha73 4 роки тому +1

    welll explained ! good job and thanks

  • @jeromegauthier5957
    @jeromegauthier5957 2 роки тому +3

    Hello, thank you for your videos :)
    In your example //4 exotic mapping I assume the variable that should have been used/indicated should be "approved" and not "balances" right?

    • @karosargsyan9686
      @karosargsyan9686 2 роки тому +2

      yes you're right

    • @amarachiugwu_
      @amarachiugwu_ 2 роки тому +2

      i noticed too, you are right, it should be approved not balance;

    • @amarachiugwu_
      @amarachiugwu_ 2 роки тому +1

      Oh, he later made the corrections, I guess I just rushed here to point out the mistake 🤦🏽‍♀️🤦🏽‍♀️🤦🏽‍♀️

  • @hillaryvictorchibuko8616
    @hillaryvictorchibuko8616 2 роки тому

    Tic tac tic tac...
    You re fired ,you didn't get the right answer
    This got me

  • @NishantSingh-zx3cd
    @NishantSingh-zx3cd 3 роки тому

    nicely explained

  • @rayed572
    @rayed572 2 роки тому +1

    Thank you Julian, your video helped me a lot to get started. Looking forward to do your courses.
    But I have a question about, What is the default value for structs in mappings? (If a struct is not assigned in a mapping) - Is it possible to do so or have to access each value of struct separately?

    • @hillaryvictorchibuko8616
      @hillaryvictorchibuko8616 2 роки тому

      You can also have access to a struct using arrays..not only mappings

    • @hellothere248
      @hellothere248 2 роки тому

      "How to initialize a struct?" Maybe this is the question you ask?

  • @AhmedKhan-rt6oz
    @AhmedKhan-rt6oz 2 роки тому

    By the way I downloaded your free course Smart contract security which is actually paid in your website

  • @neilkevin2998
    @neilkevin2998 4 роки тому +1

    Hi julian. Great work! This video tutorial has helped me a lot to build my first ethereum Dapp.
    A newbie question: lets say I'm storing data inside a mapping (string=>uint). When i make function call from my web app to the mapping storage variable function, it returns 0 if there's no match and stored uint value if thrs a match as expected. Incase the value is non zero (i.e, there a matched value inside the mapping) how do i get the transaction hash of the corresponding matched input along with the return value?

    • @EatTheBlocks
      @EatTheBlocks  4 роки тому

      I am not sure to understand the question, but you get the tx hash of a transaction with web3 or ethers, outside of the blockchain

  • @madben
    @madben 2 роки тому

    very helpfull

  • @MotherCoin
    @MotherCoin 3 роки тому

    Thank you

  • @pankajjoshi8292
    @pankajjoshi8292 2 роки тому

    Thanku lots

  • @yashdeore473
    @yashdeore473 3 роки тому

    another instructive video.

  • @user-wr4yl7tx3w
    @user-wr4yl7tx3w 3 роки тому

    Are you saving that automatically all variables get initialized to default values?

  • @user-wr4yl7tx3w
    @user-wr4yl7tx3w 3 роки тому

    For Boolean, is setting it to false , the same as deleting?

  • @pranavgor4457
    @pranavgor4457 4 роки тому +1

    How to get the length of array nested inside mapping ? I want to iterate through the array so I need to know the length

    • @EatTheBlocks
      @EatTheBlocks  4 роки тому +1

      you can access the length property, like for arrays that are not nested in mappings

  • @shubhajitroy1787
    @shubhajitroy1787 4 роки тому +1

    What is the meaning of "msg.sender"

    • @EatTheBlocks
      @EatTheBlocks  4 роки тому +4

      the address that sent the transaction

  • @yuong8139
    @yuong8139 4 роки тому

    Is the nested mapping similar to a "join" operation in sql? If so am I right to assume that it is similar to a "full join" in sql since all the nested mapping data have corresponding connection with the original mapping data?

  • @alaburausmanaliyu9949
    @alaburausmanaliyu9949 4 роки тому

    I love your tutorials but why is it that a struct can only take 7 to 8 variables anthing more than that will result to stack too deep error

    • @EatTheBlocks
      @EatTheBlocks  4 роки тому +1

      That's a limitation of the EVM (Ethereum virtual machine). We just have to work with this limitation. You can pack several piece of data into one by using arrays, mapping bytes on the field of your struct

  • @suyash-mehare
    @suyash-mehare Рік тому

    5:34 😅