Search Results
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 |
1
vote
How can I verify if a PDA exists in solana program (using Rust)?
The code in our instruction that checks if an account is already initialized is something like:
if **profile_pda_account.try_borrow_lamports()? > 0 {
msg!("This account has been initialized");
…
4
votes
Best way to keep track of all the PDAs that has been created by my program in Solana
EDIT:
Based on additional context provided, it seems like what you'd need is a pda for each user that tracks how much SOL they purchased, and a shared pda for all users that tracks how much SOL has been …
2
votes
Anchor init PDA fails with "signer privilege escalated"
The signer privilege escalated error tells us that your instruction is making a CPI but the signer it receives is not what it expects.
In this particular instance what's happening is that a CPI is bei …
2
votes
Accepted
Create PDA with no data in it
You can create a PDA with an empty account struct. … Yes a program will be able to withdraw sol from the PDA. By default, making the PDA a program account(as is done above) ensures that only the program can sign withdrawals from that PDA. …
4
votes
Validation check on inputs
Yes, PDAs are exactly what you should use. That enforces uniqueness and makes it such that only one possible address can be generated for a particular username. Other attempts to sign-up with the same …
1
vote
What is the recommended way of transferring Sol via a PDA after using SetAuthority?
For the rust code, here's example code of me doing something similar, transferring spl-tokens from a token vault with a PDA as its authority:
let transfer_instruction = Transfer {
from: funds_pot.to_account_info … ;
Here campaign is a PDA whose seeds are used as signer for the instruction because it's the authority of the funds_pot token account. …
0
votes
Anchor - Manually setting program account discriminator
You'd first have to bring the Discriminator trait into scope with use anchor_lang::Discriminator;
Then your code would be:
let discriminator = MyAccount::discriminator();
discriminator.serialize(&mut …
6
votes
Accepted
Anchor: How to set a PDA with seeds using variables from another account that is also being ...
Now as long as you derive your treasury PDA from the same name value you pass into your instruction on the client, it should work. …
1
vote
How to define a public key variable for use in the instruction with a lifetime of the Contex...
Simply deriving or hardcoding a public key on-chain is not enough to make it acceptable as an account. Any accounts you need must be passed in from the client-side. In this case the right move would i …
2
votes
Accepted
CpiContext::new_with_signer privilege escalation
You're deriving the signer_seeds wrongly. Here's how to do it:
let seeds = &[
seller.as_ref(),
"_mff_".as_bytes(),
&[campaign_bump]
];
let signer_seeds = &[&seeds[..]];
The campaign_b …
2
votes
Accepted
How do I transfer SPL-token programmatically when the recipient is the transaction signer?
You should still include the signer keys argument as &[&pda.key], it doesn't matter that the signer in this case is a pda. Also, you probably should include the token_program in your accounts. … Usually it's stored in the pda itself, during its creation, for use later. …
3
votes
Is there a way to overwrite data in an account?
Unless you increase the space allocation for your account, it can only store a maximum of the number of bytes it was allocated during initialization(in this case likely 8 + 4). Hence deserialization f …
1
vote
Deserialise getAccountInfo data from Rust rpcclient for a PDA from drift protocol
Looks like the User struct isn't serialized with Borsh on the drift side, hence deserialization that way will fail. It's a zero-copy account instead. Try using anchor's AccountLoader to deserialize ac …
5
votes
Accepted
Cannot find cause of "seeds constraint was violated" error
When deriving a PDA, the programId should be that of the program that owns whatever account whose PDA you're trying to find. …
-1
votes
Having a Solana program mint tokens while a user pays the fee
After the minting is done(Which the user pays for), you can change the authority of the mint by making a cpi call to the token program's set_authority instruction. Check for token::set_authority in th …