Skip to main content

Questions tagged [anchor-lang]

Filter by
Sorted by
Tagged with
1 vote
0 answers
13 views

Issue with spl-associated-token-account Version Conflict in anchor-spl v0.30.1

I'm working on a Solana program using Anchor, and I’ve encountered a version conflict when running cargo update with anchor-spl v0.30.1. The issue arises from the dependency on spl-associated-token-...
user24928's user avatar
1 vote
1 answer
17 views

*ctx.bumps.get("pool") Giving Error

I am trying to create a simpleswap contract. My lib.rs code is: #[program] pub mod solana_swap { use super::*; pub fn initialize_pool(ctx: Context<InitializePool>) -> Result<()>...
zubayr khalid's user avatar
0 votes
0 answers
8 views

How to Properly Interact with Pool Token Account in a Liquidity Pool Program using Anchor?

I'm working on a Solana program using Anchor that implements a liquidity pool with a loan feature. The pool is initialized and funded by users (liquidity providers) who deposit assets into the pool. ...
Suhas A's user avatar
2 votes
1 answer
28 views

Why is token_program needed when initiating an associated token account?

In the code below if I don't have token_program defined, I get compile time error. However, I am only initializing the ATA but not minting, transferring, approving, or burning the token mint which is ...
WowBow's user avatar
  • 201
0 votes
1 answer
25 views

Why my Option account is required when invoke from js client?

all. I am trying to use Option account in a demo, where, token related accounts are optional, when not provided, it will transfer SOL from my contract to user, other wise transfer SPL token to user. #...
breeze wang's user avatar
1 vote
1 answer
27 views

How to retrieve total token supply (circulating minted tokens) within a Solana program?

I'm developing a Solana program using the Anchor framework. In one of my instructions, I need to fetch the total number of minted tokens currently in circulation. I'm aware that this information can ...
benjamin james's user avatar
0 votes
0 answers
18 views

Anchor - Stuck with error SendTransactionError

I have been trying to write some custom contract in solana using Rust but always ending up with below error: Catch the SendTransactionError and call getLogs() on it for full details. at Connection....
Vishnu Vardhan Vanga's user avatar
2 votes
1 answer
44 views

How does Anchor know space needed for an ata when we don't provide space?

For vault_ata_make, how does anchor know how much space is needed since we didn't specify any space at all ? #[account( init, payer = maker, //Anchor descr is needed because of ...
WowBow's user avatar
  • 201
0 votes
0 answers
20 views

Can I use anchor address constraint with dynamic value from state

Here is the example of how address constraint is implemented, but the address is CONSTANT https://beta.solpg.io/66b37272cffcf4b13384d2aa I want to be able to change the authority who signs the ...
Nazar Havryliuk's user avatar
1 vote
1 answer
64 views

Which anchor version to use

I rarely tried to write Solana programs and have a dev question. I notice that Solana pretty often updates versions. Half a year ago I was trying to write token programs, and the Anchor 0.27 -> 0....
Nazar Havryliuk's user avatar
1 vote
0 answers
26 views

Cross-program invocation with unauthorized signer or writable account : Anchor Tip Program Error

here is the code, the error occurs in withdraw function, i used program ( tip program ) itself as authority: use anchor_lang::prelude::*; use anchor_spl::token::{transfer, Mint, Token, TokenAccount, ...
Rashid Iqbal's user avatar
2 votes
1 answer
43 views

Solana Anchor Program - Withdraw Functions says - Error processing Instruction 0: Provided owner is not allowed

I'm coding a tipping program where the tip function transfers the SPL token amount to a PDA address (the PDA of the program itself and the token mint). The tip function works fine, but I'm ...
Rashid Iqbal's user avatar
1 vote
1 answer
19 views

anyone knows how to use CPI to transfer from a pda to a normal account(just has it pubkey),btw by using Anchor

it's my transfer code, but of course it goes error. #[derive(Accounts)] pub struct random<'info>{ #[account( mut, has_one = pubkey!(HqqNdVUmtcrJADTz3mKvJrn6cCXgxAaq15nsdRZnpnko) ...
papi's user avatar
  • 129
2 votes
1 answer
82 views

error[E0635]: unknown feature `stdsimd`

I am following the tutorial out of the Solana courses. These are my dependencies: [dependencies] solana-program="1.16.27" anchor-lang = "0.29.0" switchboard-v2 = "0.4.0" ...
Mr.H's user avatar
  • 61
1 vote
0 answers
48 views

init_if_needed causing "access violation in stack frame 5"

Just like the title says, I am running into issues where i get "failed: Access violation in stack frame 5 at address 0x200005fd8 of size 8" but only when using init_if_needed, without it the ...
devtonic's user avatar
0 votes
1 answer
30 views

"Anchor Solana: InvalidProgramId Error When Passing AccountInfo for SOL Pool PDA

I'm trying to write a ICO contract with Anchor, which supposed to transfer SOL from user to program PDA account, and receives corresponding ico token. Now I'm facing strange behaviour that ...
cablespecific's user avatar
1 vote
1 answer
68 views

struct takes 0 lifetime arguments but 1 lifetime argument was supplied expected 0 lifetime arguments

use crate::curve::quadratic_curve::{QuadraticCurve}; use crate::utils::mpl::{create_metadata_accounts_v3, CreateMetadataAccountsV3cpi, Metadata}; // use crate::utils::token::{create_mint, ...
papi's user avatar
  • 129
0 votes
1 answer
27 views

Unable to deploy a Hello World contract

I have created a very simple Hello World using anchor framework, rust, and Solana. But I am unable to deploy it, due to rust's version discrepancy. Refer the below image I have tried all types of ...
ispostback's user avatar
1 vote
0 answers
80 views

Getting this error in anchor while doing anchor build [duplicate]

error: custom attribute panicked --> programs/cpi-programs/src/lib.rs:6:1 | 6 | #[program] | ^^^^^^^^^^ | = help: message: Safety checks failed: Failed to get program path error: could not compile ...
iamjoey.sol's user avatar
1 vote
1 answer
27 views

Why does has_one does not work?

So, i am making a escrow contract in solana, using anchor. I have this accept_job function. pub fn accept_job(ctx: Context<AcceptJob>) -> Result<()> { let escrow_account = &...
Saksham Chaudhary's user avatar
6 votes
4 answers
778 views

Suddenly getting error message: Safety checks failed: Failed to get program path

Suddenly getting message: Safety checks failed: Failed to get program path error message during anchor build anchor version 0.30.0 solana version 0.18.17
blackhorse's user avatar
1 vote
1 answer
31 views

Error Message: A seeds constraint was violated. The ts client does not correspond to the pda of the Solana program

Issue I encountered a strange issue where the PDA found using findProgramAddressSync in the TypeScript client does not match the PDA found in the Solana program instruction account structure, despite ...
jin yang's user avatar
1 vote
1 answer
35 views

Referencing an account from another within #[derive(Accounts)] [duplicate]

I am following this tutorial to build a lottery on Solana, which works totally fine on Solana Playground / https://beta.solpg.io/, but once i move the code to Visual code i'm getting some errors. ...
aDvo's user avatar
  • 113
3 votes
1 answer
84 views

Solana call mint token from pda program: Cross-program invocation with unauthorized

I am come from evm to Solana so I have question in evm we have modifier call is_owner... so in Solana how it work, as I understand using cpi here is my code I create custom token create.rs use { ...
Peter Jack's user avatar
2 votes
2 answers
192 views

How to Convert from Account<'info, TokenAccount> to UncheckedAccount<'info>

Please help me convert from -> #[account(mut)] pub user_token_source: Account<'info, TokenAccount>, into -> /// CHECK: Safe. user source token Account. user Account to swap from. #[...
att's user avatar
  • 161
1 vote
1 answer
185 views

Anchor build not working

When I try to run anchor build in my terminal, this is the result I am getting in the terminal. I have uninstalled and installed rust but I am still getting the same output.
Timilehin Israel's user avatar
0 votes
0 answers
9 views

How to keep sol and spl both as collateral In solana escrow program in anchor. I am really confused

So i am using anchor escrow program. Now how can i keep sol as collateral in program. Also my phantom wallet does not show the amount of sol being kept as collateral
ajaythxkur's user avatar
1 vote
1 answer
120 views

How do I build a transaction using `declare_program!` with anchor_client?

If I try to create a transaction using declare_program! for accounts and args and anchor_client for building the transaction: use anchor_lang::prelude::*; declare_program!(my_program); use my_program::...
Jon C Fan's user avatar
  • 5,229
1 vote
1 answer
96 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
  • 187
2 votes
2 answers
116 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
  • 45
2 votes
1 answer
26 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
  • 5,442
1 vote
2 answers
113 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
96 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
49 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
1 vote
0 answers
33 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
2 votes
1 answer
49 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
  • 5,442
0 votes
2 answers
253 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
58 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
  • 169
1 vote
2 answers
111 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
37 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
100 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
51 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
  • 129
1 vote
0 answers
19 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
  • 129
1 vote
1 answer
256 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
  • 129
2 votes
0 answers
212 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
  • 129
1 vote
1 answer
76 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
  • 496
0 votes
1 answer
65 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
  • 5,442
0 votes
1 answer
88 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
1 vote
1 answer
78 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
115 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

1
2 3 4 5