Skip to main content
6 votes
Accepted

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

This isn't working for you because create_with_seed doesn't generate a PDA! Use Pubkey::find_program_address if you want that. So your code will look like: const SEED: &[u8] = b"My Seed";...
Ellie High's user avatar
  • 1,084
5 votes
Accepted

How to use u64 as seed

The seeds should be: #[account(init, seeds = [b"seed1".as_ref(), &id.to_le_bytes()], bump, payer=payer, space = 50)] async function getPda(id) { return await web3.PublicKey....
James's user avatar
  • 309
4 votes
Accepted

Are there any rules as for what derived path can look like?

Technically, it could be anything, but it probably won't be supported by any wallets or tools. The derivation path like m/44'/501'/0'/0" defines a tree to follow from a seed to the actual key, so ...
Jon C's user avatar
  • 17.8k
3 votes
Accepted

When importing wallet by mnemonic phrase, how can I check whether it is correct or not?

try something like: if(bip39.validateMnemonic("test test test....junk") === true) { // do things }
spaghetti's user avatar
  • 341
3 votes

Instruction index: 0 Reason: A seeds constraint was violated. Getting this while testing in playground for the UpdateFund ctx

This is happening because in the create_fund instruction, you increase the fund_count by 1 with this line: // Incrementing total fund accounts user_profile.fund_count = user_profile.fund_count....
acheron's user avatar
  • 2,809
3 votes
Accepted

When importing a mnemonic phrase into a phantom app, the wallet addresses do not match

In case someone encounters the same problem, I will leave an answer to my question. The problem is that phantom find first key derivation along the path m/44'/501'/0'/0'. To get a wallet with the same ...
Leo Loki's user avatar
  • 434
3 votes

Recover address wallet

Code Snippet Step 1: import lib: import { bs58 } from "@project-serum/anchor/dist/cjs/utils/bytes"; import { web3 } from "@project-serum/anchor"; Step 2: Call function: const ...
Abdullah Qureshi's user avatar
3 votes
Accepted

Can't initialize PDA cause of seed constraint, even though seeds are correct

You are accepting two arguments in send_request function: request: Request, i: u8 But only mentioned one argument in the instruction: #[instruction(i: u8)] Replace the above with #[instruction(request:...
0xShuk's user avatar
  • 1,981
3 votes
Accepted

How to generate address out of a seed phrase and a derivation path for Solana and some tokens?

Regarding keygen The solana-keygen CLI tool that comes with the Solana suite includes a recover instruction that does what you need. Typically, you'll do: $ solana-keygen recover -o key.json prompt:// ...
Jon C's user avatar
  • 17.8k
3 votes

Variable seeds for PDA

Your design as proposed just fundamentally has that race condition in it. If another user beats you to instantiating Account #123, your attempt to do so will fail and you'll have to try again with #...
HelmetFace's user avatar
  • 1,787
3 votes

Use u64 as PDA seed

Well, finally I solved it using: Js: async function getPDA(id) { return await web3.PublicKey.findProgramAddress( [Buffer.from("seed1"), new BN(id).toArrayLike(Buffer, "be&...
user3688985's user avatar
3 votes
Accepted

CPI call succeeds with one input and fails with another one (same length)

The program is panicking because it Could not create program address with signer seeds: Provided seeds do not result in a valid address . This means that the PDA lies on the curve. This is happening ...
Dhruv D Jain's user avatar
3 votes

CPI call succeeds with one input and fails with another one (same length)

The issue here was that the master program wasn't owning the PDA. Hence, the CPI with seeds (and program ID) would in some cases yield a PDA that wasn't outside of the curve. And hence the runtime ...
blasrodri's user avatar
  • 205
3 votes
Accepted

How to use timestamp as seed for my PDA?

Question is why you wanna do this. If you just want a unique PDA you could just save a counter in an account and increase it with every new PDA like here: https://github.com/brimigs/solana-payroll/...
Jonas H.'s user avatar
  • 6,352
2 votes
Accepted

Solana mobile sdk seed vault unauthorized

This could be for one of several reasons: Do you have the impl project installed? It provides the reference implementation of the Seed Vault APIs, which are consumed by the fakewallet app. One thing ...
Steven Laver's user avatar
2 votes

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

You would have to manually iterate over all possibilities for the seeds, generate the PDA and then check if the account exists.
Henry E's user avatar
  • 3,100
2 votes

Error processing Instruction 0: Cross-program invocation with unauthorized signer or writable account

With the way you're currently defining margin_account's seeds in your anchor program, your frontend derivation should be thus: async getMarginAccountPda(mainAccountPubkey: PublicKey, marginOwner: ...
Ademola's user avatar
  • 3,894
2 votes

How to use timestamp as seed

we had a similar challenge some times ago and we solved like the following: use crate::{ errors::VyperVaultsErrorCode, state::{EpochData, VaultConfig}, }; use anchor_lang::prelude::*; use ...
vanderlinde's user avatar
2 votes

Unauthorized signer on CPI transfer call

For any call involving signing for a program derived account, before attempting to submit the actual signed transaction I'd advise logging with msg!() the provided PDA, as well as the one that you ...
mega_creamery's user avatar
2 votes

I'm facing custom program error: 0x0 when try to derivated a PDA with custom seeds

Are you running the test on devnet? If so, the error you're encountering could be due to the account having been initialized previously. Since you're using the wallet pubkey as one of the seeds, it ...
john's user avatar
  • 7,622
2 votes

How to use timestamp as seed for my PDA?

I assume the usage of timestamp is "not recommended" but it may depend on your use case. I believe (while feel free to test) that the definition #[account( init, seeds = [b"DATA&...
chalda's user avatar
  • 1,442
2 votes
Accepted

Solana Keygen Pubkey Prompt Won't Let Me Type

You're still typing, just the command doesn't reveal what you are typing. This is typically used with sensitive information like passwords or in this case a seed phrase. Try just typing the seed ...
Pixeled's user avatar
  • 476
2 votes

Can I recover one of my wallets without having my private key or seed phrase?

If you've lost both the seed phrase and/or private key(s) then I'm afraid its gone for good.
Needleski's user avatar
2 votes
Accepted

How to create shard accounts to manage "unlimited" account size

Something like this should do the trick: Each account is derived using a fixed seed and an increasing offset. We initialize storage accounts with length 0 and dynamically realloc them every time we ...
McBain's user avatar
  • 5,229
2 votes
Accepted

Anchor: Do I need to validate PDAs when passing them into my program?

Not really, But you should. You can do it as suggested using an anchor constraint in the #[derive(Accounts)] struct #[account( seeds = [b"some_seed"], bump, seeds:...
Jimii's user avatar
  • 5,482
1 vote

Anchor PDA Seed

Yes, you could use a hash for that like so: #[derive(Accounts)] #[instruction(level_seed: String)] pub struct InitPlayer<'info> { #[account( init_if_needed, payer = signer,...
Jonas H.'s user avatar
  • 6,352
1 vote

Instruction index: 0 Reason: A seeds constraint was violated. Getting this while testing in playground for the UpdateFund ctx

#[derive(Accounts)] #[instruction()] pub struct UpdateFund<'info>{ #[account( mut, seeds = ["fund".as_bytes(),authority.key().as_ref()], bump, ...
Doublers Kay's user avatar
1 vote

Can't initialize PDA cause of seed constraint, even though seeds are correct

You can replace #[instruction(i: u8)] with #[instruction(request: Request, i: u8)] or simply change send_request function parameters arrangement to i: u8, request: Request
bandittu's user avatar
1 vote
Accepted

How to use timestamp as seed

Only thing that pops out at me is to change: #[instruction(timestamp: String)] to: #[instruction(players: Vec<Pubkey>, timestamp: String)] Because you need the 1st-nth arguments from your ...
HelmetFace's user avatar
  • 1,787
1 vote

How can I generate a new wallet based off of a seed phrase

This is due to hierarchical derivation, which essentially defines many different ways of generating a private key from a seed phrase. For example, given a seed phrase like immense soup feed arrest ...
Jon C's user avatar
  • 17.8k

Only top scored, non community-wiki answers of a minimum length are eligible