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";...
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....
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 ...
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 }
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....
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 ...
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 ...
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:...
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://
...
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 #...
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&...
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 ...
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 ...
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/...
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 ...
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.
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: ...
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 ...
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 ...
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 ...
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&...
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 ...
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.
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 ...
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:...
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,...
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,
...
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
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
seed × 34pda × 18
anchor × 9
account × 7
solana-program × 5
wallet × 5
rust × 4
javascript × 3
keypair × 3
bump × 3
address × 3
web3.js × 3
solana-keygen × 3
private-key × 3
transfer × 2
cpi × 2
phantom × 2
phantom-wallet × 2
testing × 1
associated-token-account × 1
security × 1
anchor-test × 1
typescript × 1
sol × 1
mobile × 1