Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
3
votes
init_if_needed anchor-lang version
Hey looks like the dependencies are not correct anchor-lang 0.25 expects also anchor-slp 0.25. Also it should be init-if-needed not init_if_needed try
[dependencies]
anchor-lang = {version = "0.25.0", …
2
votes
Accepted
Need explanation of why one transfer instruction works but the other doesn't
if the account you are subsctracting from is not a PDA it will most likely be owned by the system program so you need to use a CPI for that like so:
let cpi_context = CpiContext::new(
ctx …
1
vote
Can we pass array of unchecked accounts as an array in solana anchor program?
You could have a struct with a Vec. That way you could access all the accounts, but in solana you would need to pass in all the accounts you want to interact with into the transaction. So that would n …
1
vote
An Error Occured: Error: Reached maximum depth for account resolution
This is a client anchor problem. Make sure you update to the newest anchor version.
If that does not help you can use accountsPartial or accountsStrict instead of just accounts and put in all the need …
1
vote
Inconsistent Results Running The Same Code In Playground
This is most likely happening because sometimes the transaction is already confirmed when you request the new account data and sometimes it is not.
You can await the confirmation of a transaction like …
2
votes
How to convert Vec<u8> to typescript bytes?
You can get the data types from an anchor program via the js types that anchor exports automatically. You can find them next to your output in the target folder after you build and deploy your program …
2
votes
Is it possible to fetch user account balance in smart contract?
Hey yes you can always access the lamports of an account that was passed into the transaction like so :
let lamports = ctx.accounts.player.lamports();
or mutable
**ctx
.accounts
…
3
votes
Accepted
Zero_copy not working , Getting `Zeroable` is not implemented for `[Event; 25000]`, while tr...
I guess the example is out of date in Anchor 27 there was a breaking change for zero copy:
"lang: account(zero_copy) and zero_copy attributes now derive the bytemuck::Pod and bytemuck::Zeroable traits …
1
vote
Accepted
*ctx.bumps.get("pool") Giving Error
You are right, this changed in newer anchor versions.
You can now directly access the bump like this:
let bump: u8 = ctx.bumps.pool;
3
votes
Anchor build failing with "Safety checks failed: Failed to get program path" despite correct...
Looking at the anchor code here is what it sais about this error:
https://github.com/coral-xyz/anchor/blob/master/lang/syn/src/idl/program.rs#L162
let program_path = get_program_path();
if program …
1
vote
How to handle both SPLs and native SOL token in my contract?
You need to wrap sol in the client and then you can use it like a normal SPL token.
Afterwards you can unwrap it again.
https://solana.com/de/developers/cookbook/tokens/manage-wrapped-sol
0
votes
Get account public key in an Anchor program
for example like so:
const ADMIN_PUBKEY: Pubkey = pubkey!("4j9iNoHBY34rksAwJmHHCooRbAVxo2vajCHQWKo3Hwii");
#[account(
mut,
address = ADMIN_PUBKEY
)]
pub admin: Signer<'info>,
Here is a full …
2
votes
Accepted
Signer issues with anchor tests
Looks like your state should be a PDA so that your program can sign for it.
This would like smth like this:
#[account(
init,
seeds = [b"state".as_ref()],
bump,
space …
3
votes
Is there a way to deploy same contract with new program id?
Depending on how you deploy your program you need to do it differently.
In solana play ground for example you can click the little gear icon on the top left and there you can create a new program id.
…
2
votes
Accepted
What is a consistent way to fund(airdrop) to new accounts on devnet in your Anchor test prog...
You could use always the same keypair that already has sol.
For that you can for example use the Solana Helpers:
https://github.com/solana-developers/helpers/blob/main/src/lib/keypair.ts
If you need a …