All Questions
18 questions
1
vote
2
answers
36
views
How to Calculate Space for PDA Accounts with Dynamic Vectors in Solana?
I am working on a NFT staking program. I need to create a PDA account with a structure that includes a dynamic Vec.
Here's the structure:
#[account]
pub struct UserNftStakeAccount {
pub user: ...
0
votes
3
answers
433
views
cargo build works but `cargo build-sbf` and `anchor build` fail with unsupported target error
I am working on a Solana program and facing issues building my project. When I run cargo build, the build completes successfully but doesn't generate the required .so file for deployment. Additionally,...
0
votes
1
answer
23
views
Transfering sol from pda to a hardcoded account pubkey
Can i transfer money from a program owned PDA to a hardcoded pubkey without AccountInfo of the receiver ? Or do I NEED to pass it from the client?
let hardcoded_pubkey = Pubkey::from_str("----...
2
votes
1
answer
34
views
Transfering money from a pda to a user wallet with native rust
Sorry for a noob question but im writing a solana program without anchor. And I'm having a problem with transfering sol from pda to a wallet in a program.
pub fn process_instruction(
program_id: &...
1
vote
1
answer
89
views
Error Number: 2006. Error Message: A seeds constraint was violated
My rs part:
#[derive(Accounts)] pub struct CreateLottery<'info> {
#[account(
init,
payer = authority,
space = 4 + 32 + 8 + 4 + 1 + 4 + 1 + 8, // 8 for account ...
0
votes
1
answer
72
views
How to pass multiple contexts to a single function?
I'm creating a staking contract and one of the functions that takes in the deposits, I'm using a struct in the context of transferring SPL, however, to keep the records for the same I need to create ...
1
vote
1
answer
120
views
A seeds Constraint was violated
Facing error when calling stake function. Can someone explain what am I missing?
I'm running this on Solana playground and calling stake with a random amount and selecting the current wallet for ...
0
votes
1
answer
87
views
How transfer SPL tokens from PDA to usual account in clean RUST?
I have PDA created in JS this way:
let [pda, bump] = await PublicKey.findProgramAddress(
[baseAccount.publicKey.toBuffer(), Buffer.from('1', 'utf8')],
programIdPublicKey
);
baseAccount is a ...
0
votes
1
answer
55
views
Invoke Signed Mint To Instruction
if let Err(error) = invoke_signed(
&SPLIX::mint_to_checked(
token_program_account.key,
contribution_mint_account.key,
contribution_token_account.key,
...
0
votes
1
answer
304
views
Failed to reallocate account data
I want to create a PDA account to store data about participants' wallet addresses and their deposit amounts. I have used a PDA account to store this information. It works fine when I set the array ...
1
vote
1
answer
65
views
Can we withdraw lamports from a PDA which contains data?
U cannot withdraw lamports from a pda that contains data , u can only withdraw lamports from pda or normal account which is owned by system program and it should not contain any data at all...
2
votes
1
answer
150
views
How should generate account keys be treated?
If an account is not generated via PDA and is instead created as a new keypair, how should this new keypair be treated? Is it important to custody this somewhere secure?
https://github.com/coral-xyz/...
2
votes
0
answers
432
views
Setting account values using Zero Copy PDA on Anchor
I've created a 2D array (10x10) that using a PDA and zero_copy. Here is how I set it up.
pub fn setBoard(ctx: Context<SetBoard>, increment: u64) -> Result<()> {
let mut board = ...
2
votes
1
answer
61
views
How to define a public key variable for use in the instruction with a lifetime of the Context<T>
I'm trying to find a PDA address inside the solana instruction like so:
pub fn receive_payload(ctx: Context<Receive>) -> Result<()> {
//ctx.accounts.lz_receive_nonce.increment()?;
...
1
vote
1
answer
92
views
In Anchor, how do I init a callee's account that's used to create CpiContext in caller's program?
I'm trying to make CPI to the callee program to initialize a config account when I do initialization in caller's program. One of the accounts used in callee's initialization used #[account(init)], but ...
9
votes
2
answers
249
views
How to use PDAs instead of Hash maps
I'm trying to build a crowdfunding dapp and I want to store/map the Pubkey to the amount donated. I also want to get the Top 10 donors. What would have been suitable for this kind of data is hashmap ...
4
votes
1
answer
127
views
How to verify if a public key is a PDA without the seeds?
If we have a public key, how can we determine if it is a PDA? Especially in the case where we don't have any information about the source code programs related to the public key. Is it possible to ...
2
votes
2
answers
1k
views
"Error processing Instruction 0: invalid program argument" while signing transfer transaction with PDA
Can someone point out what I'm doing wrong? I'm trying to transfer SOL from a PDA to the to_account but for some reason when I call it, fails with the following error message: Error processing ...