Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
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: ...
0xfiraterdem's user avatar
0 votes
3 answers
429 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,...
David's user avatar
  • 339
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 ...
Maksim Tolstikov's user avatar
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 ...
ProgrammerForFun's user avatar
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: &...
user21930's user avatar
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 ...
ProgrammerForFun's user avatar
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 ...
Bobz's user avatar
  • 574
0 votes
1 answer
113 views

How can I send to multiple wallets from a single PDA in a single transaction?

Very new at rust and Solana development, hoping to get some advice. I am creating some blockchain functionality for a betting system. Players will bet on the outcome of a certain event by sending the ...
galilei's user avatar
2 votes
2 answers
285 views

Anchor Test has Transaction simulation failed: Error processing Instruction 0: custom program error: 0x0

So if I anchor build and then anchor deploy on the devnet and then use anchor test --skip-build --skip-deploy since I already built and deployed everything before, I find the first time around the all ...
Mark's user avatar
  • 45
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, ...
Muhammad Ali's user avatar
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("----...
DumSolProgramer's user avatar
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 ...
André Garcia's user avatar
0 votes
3 answers
78 views

Is it a waste to implement HashMap via PDAs when the value type is only a bool?

When writing smart contracts for EVM chains, I can define a mapping(address => bool). When it comes to Solana, I think I can only use PDAs to achieve the same thing? Is my understanding correct? If ...
Yan's user avatar
  • 419
1 vote
1 answer
154 views

PDA rent exemption collection to transaction fee payer error on account close

In a transaction, I’m trying to close an ATA and a PDA. The ATA is closed by calling close_account from the SPL Token 2022 crate / On Chain Program, and the rent exemption can be sent without any ...
Vincent Berthier's user avatar
1 vote
1 answer
367 views

Could not find `pda` and `state` in `mpl_token_metadata`

I have been trying to execute an anchor build command in my program, but I am facing some errors for the mpl_token_metadata package. The error is pointed out for the below block of code: use ...
Hemang Joshi's user avatar
2 votes
1 answer
178 views

Deserialise getAccountInfo data from Rust rpcclient for a PDA from drift protocol

Basically I have the following code in devnet. I want to call getAccountInfo to get some account information. I have a PDA: JD71QyQpAJvoyq4p6mfwyaw4rY9qaDLk4CQpHeuPSpEK created by the programId: ...
panicKing's user avatar
2 votes
1 answer
49 views

How is the PDA created for this program?

in this code example: use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::{ account_info::{next_account_info, AccountInfo}, declare_id, entrypoint::ProgramResult, msg, ...
FluffyMuffin47's user avatar
3 votes
1 answer
336 views

Anchor PDA Seed

I want to create an anchor PDA using the following logic: seeds = [ b"some-text", user.key().as_ref(), Vec<Pubkey>, bool ] Is this possible? The array of pubkeys are ...
AceGravity's user avatar
0 votes
2 answers
98 views

When to not use PDAs

I'm building a project that uses PDAs quite extensively. It seems to me that PDAs are very useful for almost every type of application (alternative for hash maps, storing user data etc) and not having ...
AceGravity's user avatar
7 votes
3 answers
749 views

How to withdraw SOL from a PDA

I want to use my pda as a vault. Deposit function works fine, but withdraw doesn't pub fn withdraw(ctx: Context<DepositWithdrawVault>, amount: u64) -> Result<()> { let ...
Solomon's user avatar
  • 345
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 ...
Icus1's user avatar
  • 451
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 ...
David's user avatar
  • 51
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 ...
patriciobcs's user avatar
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/...
AceGravity's user avatar
1 vote
1 answer
139 views

What seeds should I use in `invoke_signed()` for PDA derived via `create_with_seed()`

I have a PDA generated with: const SEED: &str = "My Seed"; let pda = Pubkey::create_with_seed(program_id, SEED, &owner_id).unwrap(); Where program_id and owner_id are some fixed ...
totikom's user avatar
  • 396
2 votes
0 answers
430 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 = ...
AceGravity's user avatar
3 votes
1 answer
244 views

Do I need to create ATA for TokenAccount

library: use anchor_spl::token::{ Token, TokenAccount, Transfer } Token Account: #[account( mut, seeds = [mint.key().as_ref(), b"nfts_vault_seed", from.key().as_ref()], ...
Abdullah Qureshi's user avatar
1 vote
1 answer
58 views

How can a program enforce that one of two authorities to sign a transaction?

I know I can pass in a Context to my instruction and the struct looks something like: #[derive(Accounts)] pub struct ListOfAccounts<'info> { #[account(mut)] pub ONE: AccountInfo<'info&...
coco's user avatar
  • 83
3 votes
1 answer
156 views

Is there a way to get all accounts for pda with one missing seed?

#[account( init, payer = signer, seeds = ["dummySeed".as_bytes(), party.key().as_ref(), member.key().as_ref()], bump, space = DummyStruct::LEN )] ...
Mehmet Ayd's user avatar
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...
Nagaprasad Vr's user avatar
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 ...
nowei's user avatar
  • 11
0 votes
2 answers
193 views

Having a Solana program mint tokens while a user pays the fee [closed]

I'm trying to have a Solana Anchor program mint tokens to a user's token account (so the program or its PDA should be the authority for the mint), while the owner of the token account that's receiving ...
Alessandro De Pasquale's user avatar
2 votes
1 answer
195 views

Withdraw NFT from PDA/ TokenAccount Anchor-lang

That is what am i doing, transferring my NFTs to TokenAccount with authority as stake_account which is a PDA. How can I tranfer NFTs back to a certian wallet in anchor-lang. use anchor_spl::token::{ ...
Abdullah Qureshi's user avatar
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()?; ...
Reynevan's user avatar
  • 121
1 vote
1 answer
97 views

Can I read information stored by a PDA without having to deserialize its byte array?

here is my on-chain code to create the PDA account #[derive(Accounts)] pub struct Initialize<'info> { #[account(init, payer = user, space = 20 , seeds = [user.key().as_ref()], bump)] ...
coco's user avatar
  • 83
0 votes
0 answers
35 views

How to Properly Interact with Pool Token Account in a Liquidity Pool Program using Anchor?

I'm working on a Solana program using Anchor that implements a liquidity pool with a loan feature. The pool is initialized and funded by users (liquidity providers) who deposit assets into the pool. ...
Suhas A's user avatar