Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 1343
3 votes

How can I verify if a PDA exists in solana program (using Rust)?

check inside program Add #[account(init_if_needed)] constraint to your account (in Anchor) this will initialize the PDA only if it's not already initialized. check off-chain First, you need to get the … PDA address, you'll have to use something like PublicKey.findProgramAddress source. then get the account info of the PDA which will return - if the requested account doesn't exist. …
vicyyn's user avatar
  • 4,295
1 vote
Accepted

How to allow program to withdraw SOL from wallet

you will have to create a System Account PDA for that program which then you can deposit SOL into that account and make the program use the SOL in that PDA since it has the authorization to do it. …
vicyyn's user avatar
  • 4,295
1 vote
Accepted

How to send SPL tokens from PDA account to user

Here's an example in Anchor. vault is a pda my pda seeds are pool.mint Context #[derive(Accounts)] pub struct Instruction<'info> { #[account(mut)] pub pool: Account<'info, Pool>, #[account( …
vicyyn's user avatar
  • 4,295
4 votes

What is a Program Derived Address (PDA) exactly?

We check if the passed PDA is valid (matches a PDA generated using the signer publickey as seeds). … This means if a user2 passes user1 User PDA wishing to change their username. the transaction will fail since the PDA passed doesn't match the PDA generated inside the program using the user2 (signer) …
vicyyn's user avatar
  • 4,295
2 votes
Accepted

How do I restrict the rights to the created PDA?

We check if the passed PDA is valid (matches a PDA generated using the signer publickey as seeds). … This means if a user2 passes user1 User PDA wishing to change their username. the transaction will fail since the PDA passed doesn't match the PDA generated inside the program using the user2 (signer) …
vicyyn's user avatar
  • 4,295
1 vote

How to provide program with NFT update authority without always signing

In this case, I advise you to have 2 instructions instruction 1 : assigning update authority to the program, (a System Program PDA will suffice where it will be used to sign on behalf of the program since … You have to keep track of who is the original authoritarian by using a User PDA. …
vicyyn's user avatar
  • 4,295
3 votes
Accepted

How to initialize a PDA mint in anchor

In this case, since it's a PDA. We can use it as the authority. That way the program can sign the transaction for the mint. … (The mint can be used as a signer inside the program) provide seeds and bump for the PDA #[account( init, payer = payer, mint::decimals = 0, mint::authority = mint, …
vicyyn's user avatar
  • 4,295
0 votes

how to fetch list of all pda accounts in frontend? like sale account instance to display in ...

This will return only the accounts that have that data size (Order Pda Account) example curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { "jsonrpc": "2.0", "id": 1 …
vicyyn's user avatar
  • 4,295
0 votes

How to pass an uninitialized PDA account to a CPI to initialize it without getting AccountNo...

ProgramB expects account_a to be initialized. In ProgramB, This code checks if account_a is initialized and checks the account discriminator to make sure that's the expected structure. #[account(m …
vicyyn's user avatar
  • 4,295
1 vote

How much of a PDA can a program control

a PDA is limited to how much the program offers in controllability. To elaborate. Let's say your program has a single instruction initialize that initializes a pda account. … In that case, your program cannot change the PDA after it's initialized. You add an update instruction that updates the PDA data to a certain way. …
vicyyn's user avatar
  • 4,295
0 votes

How to transfer SOL from a PDA owned by a program to a wallet

Here is an example in anchor sending SOL from PDA. … pub fn process(&mut self, bump: u8) -> Result<()> { // transfer from pda let seeds = &["sol_bank".as_bytes(), &[bump]]; let ix = anchor_lang::solana_program::system_instruction …
vicyyn's user avatar
  • 4,295