Skip to main content

Questions tagged [pda]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
2 answers
74 views

How to use timestamp as seed for my PDA?

I'm wondering what are the best practices when using timestamps as a seed to calculate a PDA (or if using a timestamp is recommended at all). I should generate the timestamp from within my program: ...
Matheus Baptistella's user avatar
0 votes
1 answer
18 views

Can i modify a account data in a program, if the account is not mentioned in the account struct?

I wanted to know if I can modify the Pda owned by the same program when not mentioned in the account struct. what i want to do is modify several PDAs at once like more than 50, So I can't pass more ...
Abhishek Faliya's user avatar
0 votes
1 answer
14 views

Anchor PDA Cross-program invocation with unauthorized signer or writable account token 2022

i'm testing the Token Extension MetaData Pointer NFT using this example: https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/nft-meta-data-pointer/anchor, but, instead of ...
0xNicko's user avatar
  • 31
0 votes
1 answer
35 views

How can I initialize a second wallet on Anchor tests?

I would like to test that a public key that doesn't own a PDA can't alter its data. I'm doing as follows: Generate a new keypair for user2 (user1 is the pubkey of the local wallet on Anchor's ...
Matheus Baptistella's user avatar
1 vote
1 answer
18 views

Can I initialize a PDA (again) after I deleted it (Anchor)?

I calculated the PDA of an account using the public key of my local wallet, then I initialized it on-chain (using the canonical bump). One of my tests tries deleting the account, which works, but then ...
Matheus Baptistella's user avatar
0 votes
0 answers
22 views

Creating PDA with Native Rust gives error: "failed: Cross-program invocation with unauthorized signer or writable account"

I am trying to create a PDA by using the user's key and the string "mainliqa" as seed on devnet. When I interect with program I get error, this is some part of the error: "...
kadir's user avatar
  • 1
0 votes
1 answer
8 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
1 vote
0 answers
18 views

How to transfer SPL token to a PDA from Phantom or Solflare

As the title, I can not transfer token to a initialized PDA from the wallet. It say errors on Phantom and Solflare: PDA address: https://solscan.io/account/...
Lê Văn Anh Tú's user avatar
0 votes
0 answers
10 views

Store and retrieve key value pair data of referral

I am trying to store the referral chain data in an Anchor account. Since we cannot use Hashmaps in Anchor, I used a Vec<Vec<Pubkey>> data type to store the referrer and referee data like ...
Dhruv Godambe's user avatar
1 vote
1 answer
45 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
1 vote
1 answer
28 views

Error sending SOL from PDA to system account

I'm writing an English auction program that tries to refund the previous bidder if they are outbid. I store funds from bidding in a PDA called auction, and attempt to send them to the previous highest ...
Mike's user avatar
  • 125
1 vote
1 answer
27 views

Problem with fetching PDA data in frontend

I am having a problem with fetching PDA data in frontend. Error: Invalid account discriminator at Nt.decode (index.js:1403:70) at En.fetchNullable (index.js:3182:57) at async createLoan (...
Jan Gospodarek's user avatar
1 vote
2 answers
56 views

Error processing Instruction 0: custom program error: 0x0

My program is to do an English NFT auction, it uses Anchor, and I'm stuck on the error Error processing Instruction 0: custom program error: 0x0 when I try to send my the transaction to initialize the ...
Mike's user avatar
  • 125
0 votes
0 answers
57 views

Transaction fails when attempting to initialize an auction program using Anchor

I've deployed a program to devnet that lets me create English auctions, and I'm trying to create an auction from my next.js frontend. This is the program I'm using. The process I'm following is ...
Mike's user avatar
  • 125
0 votes
1 answer
18 views

How to filter most recently created pdas of a program

How to filter most recently created pdas of a program, How should date be store in pda data so that we can directly filter based on the data stored in pda. For ex. filtering all pda of a program ...
ashish0411's user avatar
3 votes
1 answer
41 views

Difference between bump vs account.bump in anchor

When declaring a PDA in anchor, what is the difference between #[account( seeds = [SomeSeed], bump )] pub my_acc: Account<'info, MyAccount>, and #[account( seeds = [SomeSeed], ...
Ahri's user avatar
  • 3,325
0 votes
1 answer
28 views

Can malicious user create fake or dust PDA accounts on my program?

Let's say I have protest the init function, see bellow. Then can malicious user bypass my barrier to create dust or evil PDA account on my program? pub fn initialize(ctx: Context<Initialize>,...
breeze wang's user avatar
2 votes
3 answers
40 views

How to correctly store pda bump

When pda is created there is a bump associated with it. should that bump be stored in that pda itself or we can store it to some other pda also. which one is preferred, need those pda to sign some ...
ashish0411's user avatar
1 vote
1 answer
15 views

Checking the generated PDA against the user's PDA input

First of all, I'm new to Solana development (came from an Ethereum background), so sorry if my question is too basic. I'm following the SolDev course, I'm on course state management. I have a ...
0xbrivan's user avatar
0 votes
1 answer
40 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
1 vote
2 answers
73 views

Stack offset of 4376 exceeded max offset of 4096 by 280 bytes, please minimize large stack variables

Error: Function _ZN137_$LT$solana_randomness_consumer..InitiateWheel$u20$as$u20$anchor_lang..Accounts$LT$solana_randomness_consumer..InitiateWheelBumps$GT$$GT$12try_accounts17h8805a14f72c43977E Stack ...
dinmavr's user avatar
  • 103
0 votes
3 answers
60 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
  • 333
0 votes
0 answers
12 views

The deposit was processed with Solana Coin without exchanging honey tokens, so the deposit has not been made yet

At the phantom I didn't exchange honey tokens for solana tokens but deposited them into my solana virtual account It hasn't been deposited into my Solana coin wallet yet Help me
mih's user avatar
  • 1
0 votes
1 answer
15 views

Transaction error but program returned success

Regarding this tx: https://explorer.solana.com/tx/5XX4VPGzxYd8VQYdpcLmASokERwxVp8RtyqZ9Y2Kw5P5FVjSRS2dP5xpUqDqAfTrQs43wuV6A6HRs5M6QNjQh1iJ?cluster=devnet The program logs returned success, but it was ...
Burger Bob's user avatar
  • 1,406
0 votes
1 answer
22 views

Autonomous Pyth Price Feed Updates Without User Wallet Confirmations

I'm working on a Solana smart contract that includes functions for creating a Program Derived Address (PDA) to store price data and updating this PDA with data from Pyth price feeds. My goal is to ...
0xEbo's user avatar
  • 5
0 votes
1 answer
21 views

How to close a PDA account when the structure has been changed

I tried to close a PDA account that has changed in structure, but ran into: "Error: memory allocation failed, out of memory"
Burger Bob's user avatar
  • 1,406
0 votes
1 answer
21 views

Model a one to many relationship with PDAs

One can find many examples online of using PDAs like a hashmap structure, i.e. for a one to one relationship. How would I go about this if each of my users can have multiple instances of the same kind ...
Ahri's user avatar
  • 3,325
0 votes
1 answer
54 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
1 vote
1 answer
46 views

Does PDA owned by System Program safe?

I want to generate PDA with PublicKey.findProgramAddress and get them to users. Is there any way to withdraw funds from this PDA, outside of the Solana program, whose ID was used to create this PDA? ...
Maksim Tolstikov's user avatar
1 vote
1 answer
56 views

Are multiple transfers with a single program instruction actually occurring in sequence?

This question is related to an earlier question I had about having multiple instructions within a single transaction function. Certain transactions seem to be untrackable If there are multiple ...
ZeroNine's user avatar
  • 473
0 votes
1 answer
59 views

Unable to create a PDA TokenAccount using anchor constraints

I am trying to create a PDA TokenAccount and transfer an NFT from the users (signer) account to the created PDA. For some reason the PDA is not being created. After the transfer when i try to read the ...
Faheel Mohammad's user avatar
0 votes
0 answers
46 views

Problem with account data serialization and deserializatin

I'm working on a Solana program and encountered an issue related to state management with Program Derived Accounts (PDAs). I successfully created a state for my Solana program and saved it to a PDA (...
Nikita's user avatar
  • 1
1 vote
1 answer
58 views

Correct way to define and initialize a variable-length account in Anchor

I have been following the Tic-Tac-Toe tutorial and i am experimenting with creating a PDA account in my program that holds a variable-length list of values (in particular, public keys representing ...
munifao's user avatar
  • 43
3 votes
1 answer
90 views

In what context is the hash of a ed25519 public key used as an address?

According to the docs, a Solana address is one of the following: an ed25519 public key a program-derived account address (32byte value forced off the ed25519 curve) a hash of an ed25519 public key ...
Ahri's user avatar
  • 3,325
0 votes
1 answer
49 views

Reducing rent costs

I feel like for some base accounts, I’m getting charged 0.002 sol, which is like $0.20 to store a simple data field on a PDA. Especially for multiple data fields I want to store, this number added ...
AceGravity's user avatar
2 votes
3 answers
176 views

Anchor Program unable to sign a transfer with a PDA

I am working on an Anchor Solana program, and I've encountered an error that I'm having trouble resolving. The error is: "Cross-program invocation with unauthorized signer or writable account.&...
Gregz's user avatar
  • 23
1 vote
0 answers
28 views

Sign with multiple PDAs in Anchor using .with_signers()

I want to create an Account using SOL contained in a PDA. For that I guess I need two signatures, the payer(master) that will pay for the CPI call and the rent, and the receiver(subordinate). How do I ...
PandaPanda's user avatar
0 votes
0 answers
50 views

Get PDAs within an anchor function

I know through client side I can do this to get all the PDAs for a account type. let program = anchor.workspace.MyApp as Program<MyApp> let items = await program.account.items.all(); But what I ...
ZeroNine's user avatar
  • 473
2 votes
1 answer
87 views

Verify if PDA exists in program using Anchor

I need specifically to verify if a PDA exist inside a program without passing it as an account in the instruction. The solution I'm looking for is something like this. Thank you! let (pubkey_pda,...
PandaPanda's user avatar
2 votes
1 answer
43 views

How to pay for PDA account from another private key

I am developing a set of services for a cryptocurrency exchange on Solana and I've encountered an issue when trying to create a PDA (Program Derived Address) account within my smart contract. Here's ...
Leonid Kabanov's user avatar
2 votes
1 answer
92 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
3 votes
1 answer
42 views

Is it possible to close or create a PDA from within an Anchor function

I know I can set this up with Anchor accounts and trigger a anchor function through client side code pub fn delete_item(ctx: Context<DeleteItem>) -> Result<()> { Ok(()) } pub fn ...
ZeroNine's user avatar
  • 473
2 votes
1 answer
128 views

Return value from program function

Is it possible to return a custom value from a program function and capture this data in the client side code? //Anchor function pub fn new_item(ctx: Context<Item>, id: String) -> Result<...
ZeroNine's user avatar
  • 473
3 votes
1 answer
68 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
1 answer
32 views

How to have PDA space size depending on instruction argument

I'm using anchor, so I define the space attribute in the Accounts struct, is there a way to make it depend on the instruction arg ? It's for a PDA storing a string, and I don't know string length ...
FluffyMuffin47's user avatar
1 vote
1 answer
54 views

How PDAs prevent unauthorized accounts from signing it?

As far as I can understand, PDAs are a way for programmatically signing for an address without actually having a private key. The process of generating a new PDA is calculating sha256 hash of ...
Amir reza Riahi's user avatar
1 vote
1 answer
749 views

Transaction Error: Signature Verification Failed: Missing Signature For PublicKey

I'm building a transaction on devnet that previously worked when I tested my program. I don't think it's the program itself, but how I am passing down the signatures which is slightly different from ...
Brian M.'s user avatar
  • 111
1 vote
1 answer
37 views

Verifying transaction before PDA account creation

I want to create a PDA only if a user successfully transfers the funds. If I create a client side transaction with a PDA creation as the final transaction, can the PDA creation continue to be made if ...
ZeroNine's user avatar
  • 473
6 votes
1 answer
125 views

Does `#[account(init)]` create a PDA account or a non-PDA account?

Does the below declaration mean to create a PDA account? #[derive(Accounts)] pub struct CreatePixel<'info> { #[account(init, payer=user, space=Pixel::LEN)] pub pixel: Account<'info, ...
breeze wang's user avatar
0 votes
1 answer
34 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

1
2 3 4 5