Pda crypto

Comment

Author: Admin | 2025-04-28

Cash_account account. The seeds for the cash account PDAs arecreated from the public key of the cash account owner so the instruction needsto take the recipient's public key as a parameter and pass that to theTransferFunds Context data structure. Then the cash_account PDA can bederived for both the from_cash_account and the to_cash_account.Since both of the accounts are listed in the #[derive(Accounts)] macro, theyare deserialized and validated so you can simply call both of the accounts withthe Context ctx to get the account info and update the account balances fromthere.To be able to send funds to another user, similar to Cash App, both users musthave created an account. We're sending funds to the user's cash_account PDA,not the user's wallet. So each user needs to initialize a cash account bycalling the initialize_account instruction to create their unique PDA derivedfrom their wallet public key. We'll need to keep this in mind when designing theUI/UX of the onboarding process for this dApp later on to ensure every usercalls the initialize_account instruction when signing up for an account.Now that the basic payment functionality is enabled, we want to be able tointeract with friends. So we need to add instructions for adding friends,requesting payments from friends, and accepting/rejecting payment requests.Adding a friend is as simple as just pushing a new public key to the friendsvector in the CashAccount state.In the add_friend function, there is a design limitation. The vec of friendshas a limit to how many friends a user to can add. To enhance this program

Add Comment