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 |
8
votes
1
answer
263
views
How to recover an account after updating his account discriminator
I have tried the secure approach to prevent sea-level attacks to close my PDA account:
use anchor_lang::__private::CLOSED_ACCOUNT_DISCRIMINATOR;
use anchor_lang::prelude::*;
use std::io::{Cursor, Writ …
3
votes
2
answers
628
views
How to transfer SOL from wallet to another wallet in an Anchor program (Rust)
Is it possible to use Anchor to transfer SOL from user wallet into another user wallet without actually having to initialize program accounts?
I know someone may think that this can be easily done dir …
2
votes
1
answer
205
views
How to define fixed variables in Anchor programs
Is it possible to define a variable within the Anchor.toml file and then use it during run time inside the anchor program? I couldn't find how in the docs.
I guess an alternative could be defining the …
6
votes
2
answers
486
views
Compile error on Anchor 0.27 when using anchor-spl
I am using the following Anchor dependencies:
anchor-lang = "0.27.0"
anchor-spl = { version = "0.27.0", features = ["metadata"] }
But it breaks when compiling because seems like the create_metadata_a …
3
votes
1
answer
735
views
Calculate account size in anchor
Which would be the space required for an account containing a struct like the following anchor example?
#[derive(AnchorSerialize, AnchorDeserialize)]
pub struct MyStruct {
subfield: u8
}
#[accoun …
2
votes
1
answer
369
views
How to know if the an account already exists when using Anchor's init_if_needed feature
Is there is an easy way to know if the account has just been created or already existed when using the init_if_needed feature?:
#[account(
init_if_needed,
seeds = [seeds],
pa …
2
votes
1
answer
324
views
How to define constants in Anchor
Is there some special approach for defining constants in Anchor? I tried it normally just before the program ID:
pub const MY_CONST: &'static str = "some example str";
declare_id!("MY_PROGRAM_PUBKEY" …
4
votes
2
answers
9k
views
How to fix error Macro not expanded: proc macro crate is missing dylib
Somebody knows how to get rid of the error "Macro .... not expanded: proc macro crate is missing dylib"?
I am getting that error on pretty much every anchor macro since I have installed the newest ve …
4
votes
1
answer
191
views
How to fix Borsh serialize error on Anchor 0.28 when publishing crates
Related to the Borsh serialize error the changes suggested by @acheron only work for running the program, but doesn't work or are ignored when publishing the crate to crates.io.
For instance when runn …
1
vote
1
answer
409
views
Super slow deployments when using Solana CLI 16.x
My deployments are extremely slow since I have updated my Solana CLI to v16.8 but when I run:
anchor deploy
I get:
Blockhash expired. 4 retries remaining
Blockhash expired. 3 retries remaining
⠁ 0. …
2
votes
2
answers
307
views
How to authenticate or validate wallets or NFTs when executing solana instructions
I am building a Solana program using Anchor and I would like to know which is the recommended way to authenticate/validate users allowed to execute certain Solana instructions. For what I have seen so …
1
vote
1
answer
165
views
How to store signatures in a Solana account
Is there a cleaner way to store signatures in an account?
I mean instead of storing the 88 characters as a String. For instance Publickeys are stored as 32 Bytes instead of their corresponding 44 char …
4
votes
1
answer
88
views
Simultaneos transactions can cause race conditions in solana programs?
Simultaneous transactions could cause race conditions on a Solana program? For instance if we have the following counter example:
#[account]
pub struct Counter {
pub number: u8,
}
#[derive(Accoun …
4
votes
2
answers
254
views
SOL transfer via CPI signed with PDA throws fails
I am trying to make a SOL transfer from the bank account into the client account, but the operation fails with the following error:
Cross-program invocation with unauthorized signer or writable accoun …