Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PDA derivation logic #9

Closed
5 tasks done
irene-bbox opened this issue Dec 28, 2022 · 0 comments
Closed
5 tasks done

Fix PDA derivation logic #9

irene-bbox opened this issue Dec 28, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@irene-bbox
Copy link
Contributor

irene-bbox commented Dec 28, 2022

Description

For the longest time, we were unable to derive a PDA. Fix the derivation logic to correctly derive a PDA.

Tasks

  • invoke these surrogate functions to derive a PDA:
    • in the Rust contract use Pubkey::create_program_address()?
    • in the TypeScript client use PublicKey.findProgramAddress()
  • hard code PDA seeds in both Rust and Typescript files (seeds must match up!)
  • the TypeScript client passes some program instruction, and the program instructions contain a ProgramId. That ProgramId is the address of the Rust smart contract (program) after being deployed to devnet. So, you must first deploy the Rust contract, secondly you must fetch the deployed ProgramId, and lastly you'll pass that ProgramId to the .ts client
  • the signer of the call to the TypeScript client, will be the signer of the blockchain transaction to derive the PDA, who will also be the funding account sponsoring the PDA derivation
  • whenever you derive a PDA, consol.log these 3 pieces of info, which you'll need to interact with the PDA later on:
    • PDA public key
    • PDA seeds
    • PDA bump
@irene-bbox irene-bbox self-assigned this Dec 28, 2022
@irene-bbox irene-bbox added the bug Something isn't working label Dec 28, 2022
irene-bbox added a commit that referenced this issue Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant