Solana Tutorial: Creating PDA's with Anchor

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 มิ.ย. 2024
  • In this video we're going to learn an important development concept with Solana: PDA's or Program Derived Addresses. We will learn what they are and how to use them.
    Github: github.com/chang47/solana-pda...
    📙 Solana Playlist: • Rust Crash Course Tuto...
    💰 Donations accepted (but optional): 2hYca42EE2kwmFZPV7M4skev1za7atWBh5ctzQWfsTD7
    00:00 - Intro
    00:13 - Video Overview
    01:37 - What are PDA's
    02:10 - How are public keys represented
    02:48 - Seeds and bumps
    03:33 - Escrow Example
    05:10 - How PDA's are created on Anchor
    07:08 - Setting up project
    08:15 - Going over a anchor PDA example project
    13:30 - Note about tests
    13:57 - Conclusion
    Resource:
    docs.solana.com/developing/pr...

ความคิดเห็น • 26

  • @bunchathumbs6194
    @bunchathumbs6194 ปีที่แล้ว

    Another great tutorial! Thank you!
    Just one thing to note: if string is a utf-8 format it could take up to 4 bytes depending on what symbols are used, so the space for 20 letters should be counted as 20 multiplied by 4.

  • @rezaaslejeddian9562
    @rezaaslejeddian9562 ปีที่แล้ว

    Josh, you are doing amazing and thanks for the content

  • @imacuser101
    @imacuser101 ปีที่แล้ว +4

    I love your videos man! Keep them up!

    • @JoshsDevBox
      @JoshsDevBox  ปีที่แล้ว

      Thanks! I'm really starting to get back into it, so expect more to come soon (fingers crossed)!

  • @Solandy
    @Solandy ปีที่แล้ว +3

    Hey Josh :)
    My notes:
    7:09 We need the SystemProgram because we init an account and on Solana that is a task of the SystemProgram (createAccount) ;P
    9:10 Nice, you call it instruction now :D
    9:55 The bump is ALWAYS used! It starts out at 255 and if it's not on the curve it will stay there.. not using a bump gives you a different address though ;)
    11:00 I'm not sure about this one but I think you're missing 8 bytes for the size since you let Anchor create the account...
    Hope that helps!
    If you ever come across my videos feel free to critique them as well :P
    -Andy

    • @JoshsDevBox
      @JoshsDevBox  ปีที่แล้ว +2

      Hey Andy! It's always great to see a fellow Solana content creator! I love the enthusiasm you have in your video's!
      I really appreciate the break down, as you can see, I don't really know what I'm talking about :P

  • @leetcodeforbeginners
    @leetcodeforbeginners ปีที่แล้ว +1

    Great content

  • @prashantsoni672
    @prashantsoni672 28 วันที่ผ่านมา

    thanks

  • @87subash
    @87subash ปีที่แล้ว

    The best PDA example seen so far. Great work.
    In this example the amount is passed as a input parameter to the PDA program from the UI. Anything on UI, the user(who sign the transaction) can edit the javascript from the browser and manipulate the input parameters for the solana program. End of the day, isn't that violates the request integrity even though it's authenticated ?

    • @87subash
      @87subash ปีที่แล้ว

      This is a general question, not just about this particular example.

  • @shrikanthreddy2774
    @shrikanthreddy2774 ปีที่แล้ว

    Hi while creating the PDA in the anchor program you are passing "escrow" as a seed. is it possible to pass dynamic string here from the front end?

  • @packirisamykaran6986
    @packirisamykaran6986 ปีที่แล้ว

    looking fresh josh

  • @UniversbeCREATIONS
    @UniversbeCREATIONS ปีที่แล้ว

    Buddy make more videos on it but can you please make video which is like small project. And explain some new topics in it, in this way it's more interesting 🥰, hope you continue making this blockchain videos.

  • @anwaarali178
    @anwaarali178 ปีที่แล้ว +1

    hello i have one question we can create only one PDA from a wallet is there any way we can generate multiple PDAs from a wallet if its possible can you share some resource

    • @JoshsDevBox
      @JoshsDevBox  ปีที่แล้ว

      Your wallet isn't actually even needed for PDA's, in this example we used it as an input, but we could just as easily create a PDA that uses an integer as a PDA.
      If you're directly referencing the escrow example, then you'll need to include another input that you'll have to use to differentiate your seed.

    • @anwaarali178
      @anwaarali178 ปีที่แล้ว

      @@JoshsDevBox can you please share code or reference for including another input

  • @Fatkattful
    @Fatkattful ปีที่แล้ว +3

    Very informative and comprehensible content.
    I got one question.
    Let's say, I want to develop an application where multiple users deposit SOL and after some time based on some formula, one of the user will be paid from the balance of the contract. Is this use case possible with PDA?

    • @JoshsDevBox
      @JoshsDevBox  ปีที่แล้ว +1

      Thanks!
      Yeah it should be possible. You can't have your code execute asynchronosly after a period of time, the best you can do is set a period of time you have to wait before you can withdrawl. Once the time has past you can manually send withdrawl transaction. The program will check that enough time has passed and then randomly choose somoene to give all the balance to.

    • @Fatkattful
      @Fatkattful ปีที่แล้ว

      @@JoshsDevBox Thanks for the answer. Also, what was your problem during testing?

    • @shubhamkashyap3762
      @shubhamkashyap3762 ปีที่แล้ว

      I'm looking for the same thing for past few days, could you help me with this if you found anything on this.

    • @Fatkattful
      @Fatkattful ปีที่แล้ว

      @@shubhamkashyap3762 you mean the pda testing or you also need to store Lamports on an account?

    • @shubhamkashyap3762
      @shubhamkashyap3762 ปีที่แล้ว

      @@Fatkattful I'm working on a PvP game project, both players will bet a fix amount and that amount (SOL) will be transferred to the winner.
      I'm not sure how it will be done and constantly searching for the solution

  • @soyombo558
    @soyombo558 ปีที่แล้ว

    Does anybody know how to make staking solana smart contract. And where can i find resources ?

    • @JoshsDevBox
      @JoshsDevBox  ปีที่แล้ว

      I haven't looked much into staking, but a quick google search found some interesting implementations of it: github.com/Brent-Jeremy/solana-nft-staking

  • @aduttya
    @aduttya ปีที่แล้ว +2

    I am astonished how even you are collecting resources to build these.

    • @JoshsDevBox
      @JoshsDevBox  ปีที่แล้ว

      Thanks! Let's just say that there's a reason why the video's always come out slowly (jk, half of it was because I was doing other things)