Skip to main content

Questions tagged [anchor-lang]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
81 views

({"err":{"InstructionError":[0,"InvalidInstructionData"]}})

Here everything seems fine but still got this error please guide me here :- Place bid program. :- pub fn place_bid(ctx: Context<PlaceBid>, bid_amount: u64) -> Result<()> { ...
Aditya's user avatar
  • 113
1 vote
2 answers
24 views

Anchor Test has Transaction simulation failed: Error processing Instruction 0: custom program error: 0x0

So if I anchor build and then anchor deploy on the devnet and then use anchor test --skip-build --skip-deploy since I already built and deployed everything before, I find the first time around the all ...
Mark's user avatar
  • 33
2 votes
1 answer
18 views

passing anchor `#[instruction]` argument with another argument results in different address generated

I have my accounts struct like this #[derive(Accounts)] #[instruction(force_seed: [u8; 32])] pub struct Dummy<'info> { #[account(mut)] pub payer: Signer<'info>, /// CHECK: ...
Jimii's user avatar
  • 2,254
1 vote
2 answers
44 views

Is there a way to get program id of CPI call?

I am calling a solana program A from solana program B using cpi invokes. Is there a way to get the program id of program B on program A or a way to get the cpi is invoked?
blackhorse's user avatar
0 votes
1 answer
12 views

Error running anchor test: Unable to get latest blockhash

I'm getting a random inability to fetch a blockhash halfway through my test cases in anchor. Can't see to find a patter to it. Can anyone help? Test results: solchan-faucet [DEBUG]: Starting before ...
michaelb's user avatar
0 votes
1 answer
19 views

Is there a new method for ctx.bumps.get in 0.30.0

I've encountered a problem trying to reuse an old project. I'm trying to build the project but the cli throws this error at me: "this is an associated function, not a method" for using *ctx....
Jonathan's user avatar
0 votes
0 answers
10 views

Fee token with whitelist

Sorry for stupid question. Fee token is done, when I call transferCheckedWithFee method, token is send and fee is deducted. Now I want some users to not pay the fee. I am using transfer-hook, I used ...
Syed Mokarram's user avatar
0 votes
1 answer
11 views

What exactly are `Interface<'info, T>` and `InterfaceAccount<'info, T>`

InterfaceAccount<'info, T> and Interface<'info, T> and Anchor accounts types Would love to know more about them, where I should use them and what differentiates the two.
Jimii's user avatar
  • 2,254
0 votes
2 answers
82 views

Mainnet contract deployment hangs

I am trying to deploy my solana mainnet contract but it stuck during deployment, will it reibursable? Can I cancel it as it is taking longer time? Why it is stuck? Solana mainnet status is also good ...
blackhorse's user avatar
2 votes
1 answer
35 views

Issue while compiling the code | Using Anchor framework

I am trying to run my below code but getting error: use anchor_lang::prelude::*; use solana_program::clock::UnixTimestamp; declare_id!("FCLkGfDSoFadeVaZQRnnLu4Uy913vd7DDJMERZnvtnmq"); /// A ...
Ajit's user avatar
  • 151
1 vote
2 answers
30 views

Can we pass array of unchecked accounts as an array in solana anchor program?

What if we want to pass arbitrary number of accounts to the function(as part of accounts). Expectation :- If we have a program and there is a function named as transferMultiple (Which is responsible ...
Aravind Makam's user avatar
0 votes
0 answers
15 views

Calling mint_to for second times error: ConstraintMintMintAuthority. Error Number: 2016. Error Message: A mint mint authority constraint was violated

Initialize and Mint token functions: pub fn init_token(ctx: Context<InitToken>, metadata: InitTokenParams) -> Result<()> { let authority = &ctx.accounts.payer; let ...
Lobo1897's user avatar
  • 153
0 votes
1 answer
29 views

cannot transmute between types of different sizes, or dependently-sized types

Problem I encountered this issue while using zero_copy, as shown below: error[E0512]: cannot transmute between types of different sizes, or dependently-sized types --> programs/solot/src/state.rs:...
jin yang's user avatar
1 vote
0 answers
19 views

Program returned error: "Overlapping copy"

I tried to mint NFT to someone , but it gives me a error "Error: Raw transaction 5A6sSQPmAUBTQXDkrz9DM1tkYnwp7mjFLLi2S2cUpVjxnkYXHaSvHLHq2fz7Z5ViDdghrAgKPwqBVDC5m7ud3oEK failed ({"err":{...
papi's user avatar
  • 79
1 vote
0 answers
16 views

Try to create mint and ATAaccount shows Error:Transaction simulation failed:Error processing Instruction 0:Program failed to complete

Try to create mint and ATA account, When I run anchor test, it shows Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Program failed to complete here ...
papi's user avatar
  • 79
1 vote
1 answer
78 views

Error: target/idl/sol_404.json doesn't exist. Did you run `anchor build`?

I run anchor build , and it indeeded generate a sol404.json , but when I run the anchor test it shows /Users/brooke/Desktop/sol404/node_modules/.bin/ts-mocha -p ./tsconfig.json -t 1000000 'tests/**/*....
papi's user avatar
  • 79
1 vote
0 answers
53 views

Error: AnchorError caused by account: token_metadata_program. Error Code: InvalidProgramExecutable. Error Number: 3009

I run anchor test and then it shows Error: AnchorError caused by account: token_metadata_program. Error Code: InvalidProgramExecutable. Error Number: 3009. Error Message: Program account is not ...
papi's user avatar
  • 79
1 vote
1 answer
48 views

CLOSED_ACCOUNT_DISCRIMINATOR removed from 0.30

In Anchor 0.29 I was manually closing out accounts in my contract like this. let item_account_info = ctx.accounts.item.to_account_info(); let mut data = item_account_info.try_borrow_mut_data()?; for ...
ZeroNine's user avatar
  • 485
0 votes
1 answer
17 views

Is it possible to figure out which instruction is causing the stack access violation

Getting this error which means I'm probably putting too much on the stack. is it possible to find out the exact instruction that is causing this? Or does this error mean that everything on my program ...
Jimii's user avatar
  • 2,254
0 votes
1 answer
41 views

anchor_lang::AccountDeserialize

How to implement correctly try_deserialize and try_deserialize_unchecked for this Example struct? I've been trying, but failing miserably. #[derive(Clone)] pub struct ExampleProgram; declare_id!(&...
beliveN DAOist.dev's user avatar
0 votes
1 answer
56 views

How to transfer SOL to remaining_accounts from the signer account

I am trying to transfer 0.1 SOL from the signer account to all the accounts passed in the remaining_accounts to the function call. Here's a breakdown of the code. anchor pub fn purchase_package(...
Dhruv Godambe's user avatar
1 vote
1 answer
61 views

Problems deploying and testing with Anchor on Devnet

I am getting this error when trying to test and deploy my program using Anchor. Error: Deploying program failed: RPC response error -32002: Transaction simulation failed: Error processing Instruction ...
gconnect's user avatar
0 votes
0 answers
12 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
2 votes
2 answers
79 views

Zero_copy not working , Getting `Zeroable` is not implemented for `[Event; 25000]`, while trying example

I'm trying This example by anchor to initialize large accounts and using zero_copy on them. https://github.com/coral-xyz/anchor/blob/master/tests/zero-copy/programs/zero-copy/src/lib.rs#L156-L165 I'm ...
Abhishek Faliya's user avatar
1 vote
1 answer
83 views

mpl-token-metadata 4.1.2 causing issues

I have been working to update this code to solana 1.18.8, anchor 0.29.0, and mpl-token-metadata 4.1.2. I have repaired most of the issues except 3. I have tried importing create_metadata_account_v3 ...
Sweet Gum's user avatar
1 vote
1 answer
32 views

how to use `sighash` function from `anchor-syn` crate in my on-chain code?

I have on-chain code to calculate instruction discriminator as : use anchor_syn::codegen::program::common::{sighash, SIGHASH_GLOBAL_NAMESPACE}; // use anchor_syn::hash::hash; // module `hash` is ...
breeze wang's user avatar
2 votes
1 answer
53 views

Why anchor-lang v0.29.0 introduce v1.18.3 'solana-program'?

I create a anchor project that only depend on anchor-lang = "0.29.0" in Cargo.toml One thing I can't understand is that after cargo add or update, the 'solana-program' version inside Cargo....
breeze wang's user avatar
1 vote
1 answer
91 views

How to think about monthly subscriptions in Solana

I am looking to build a Monthly subscription program in anchor/Solana that allows a user to subscribe to a SPL token subscription (like USDC or SOL) such that the recipient automatically receives the ...
AceGravity's user avatar
0 votes
0 answers
63 views

Error: AnchorError occurred. Error Code: InstructionFallbackNotFound. Error Number: 101. Error Message: Fallback functions are not supported)

I am building an app on Solana using Anchor, and everything works when I'm testing on localnet, but whenever I switch to devnet, I'm getting the error when I call any program method. Error: ...
sammyd's user avatar
  • 1
0 votes
1 answer
61 views

Validate secp256k1 ethereum signature?

I’m working on an anchor-lang project to validate secp256k1 ethereum signature. I used secp256k1_recover program docs as a reference for this code. The problem is that the public key I get from the ...
Teodor Zafirov's user avatar
1 vote
1 answer
46 views

NFTs on anchor tests

I'm trying to use this guide to create an NFT to test with my anchor program. When I attempt to mint the NFT, I am met with the following error. FailedToSendTransactionError: The transaction could not ...
Morgandril's user avatar
2 votes
1 answer
47 views

Signer issues with anchor tests

i'm getting a weird signer error when running my tests; Error: Signature verification failed. Missing signature for public key [`6jAudYFBbfQS59oPNjYcMkqr9MqBf312T7oP6WSYRjsg`]. In this case, ...
Morgandril's user avatar
1 vote
0 answers
27 views

Address from pubkey

I need to be able to derive an anchor.Address object from a solana/web3.js::Pubkey object based on this error I receive in editor: Type at position 2 in source is not compatible with type at ...
Morgandril's user avatar
1 vote
1 answer
470 views

What is the meaning of "custom program error: 0x1771" erro?

what is the meaning of custom program error: 0x1771 error?
blackhorse's user avatar
1 vote
0 answers
31 views

Solana 1.17+, what processor should be used when instantiating ProgramTest::new()?

I recently upgraded from Solana 1.14 to 1.17.22 and I'm not able to write rust tests that way I've previously been able to. Specifically, previously, when instantiating ProgramTest::new I've typically ...
Ted's user avatar
  • 11
1 vote
2 answers
75 views

Is there any rust function available for getParsedAccountInfo similar to typescript from solana/web3 library?

I am trying to derive AccountInfo from given public key on Rust, Is there any similar anchor function available like getParsedAccountInfo from solana/web3 library?
blackhorse's user avatar
2 votes
1 answer
279 views

What is the meaning of custom program error code 0xc?

I am trying to test my program but I am getting Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0xc Can someone suggest the ...
blackhorse's user avatar
0 votes
0 answers
57 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
  • 485
0 votes
1 answer
177 views

Why my minted spl-token-2022 not coming up on phantom wallet?

I have created my spl-token-2022 from anchor smart contract but the minted tokens are not showing on my phantom wallet. What could be the possible reasons for this? This is my token https://solscan.io/...
blackhorse's user avatar
1 vote
1 answer
67 views

Need explanation of why one transfer instruction works but the other doesn't

I have a simple account like so. #[derive(Accounts)] pub struct CreateItem<'info> { #[account( init, payer = creator, space = ITEM_SIZE, seeds = [ITEM_SEED], ...
ZeroNine's user avatar
  • 485
4 votes
1 answer
76 views

How do you call other Anchor functions within another Anchor function?

Within a function, how do I call other functions? pub fn process_a(ctx: Context<CreateItemA>) -> Result<()> { /// Do something things with item A here... /// Now call process_b? ...
ZeroNine's user avatar
  • 485
3 votes
1 answer
45 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
  • 485
2 votes
1 answer
173 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
  • 485
1 vote
1 answer
156 views

How to increase the PDA size after deployment with anchor framework

Is there a way to increase PDA size after contract deployment using anchor framework. Here is the reference of doing the same with realloc, https://dev.to/jacobcreech/how-to-change-account-size-on-...
blackhorse's user avatar
2 votes
3 answers
494 views

Is there a way to deploy same contract with new program id?

I have to deploy same solana programs with differnt different program ids, how can I do it?
blackhorse's user avatar
1 vote
1 answer
68 views

What is the interface and accountinterface in anchorlang

What is the purpose of Interface<'info, T> and InterfaceAccount<'info, T> and in what scenario might I need to use them?
Jimii's user avatar
  • 2,254
2 votes
1 answer
60 views

How to catch error or throw custom error if PDA doesn't exist in Solana program

Is there a way to throw custom error if PDA account does not exist in a Solana program?
blackhorse's user avatar
3 votes
2 answers
194 views

Is it possible to fetch user account balance in smart contract?

Is it possible to fetch account balance or token balance in the smart contract itself?
blackhorse's user avatar
1 vote
1 answer
26 views

can we store values in constant at the time of program deployment?

I'm working on a Solana program and would like to understand if it's possible to set constant values during program deployment, similar to constructor parameters in other smart contract platforms. ...
Vivek Kadavni's user avatar
2 votes
1 answer
50 views

How can I fix Error Code: InstructionFallbackNotFound?

Today I had this error that took me a while to determine what was happening. 1) Create suscription Is initialized!: Error: AnchorError occurred. Error Code: InstructionFallbackNotFound. ...
Mateo Lafalce's user avatar