Skip to main content

New answers tagged

0 votes

I want to add liquidity into Raydium programmatically

This is good practice. https://github.com/raydium-io/amm_anchor/blob/master/tests/amm-proxy/programs/amm-proxy/src/instructions/deposit.rs I've tested and working correctly!
Alan Daniela's user avatar
1 vote

Avoid unnecessary account generation

I think there are multiple approaches how to manage your code. I can put some that're coming to my mind. Having two accounts and using the Anchor init_if_needed (https://www.anchor-lang.com/docs/...
chalda's user avatar
  • 752
1 vote

Making an UncheckedAccount a signer in some conditions

There could be but I'm not aware of such functionality within Anchor. I would probably use two separate instruction input accounts. One is the required non-signer UncheckedAccount<'info> and the ...
chalda's user avatar
  • 752
1 vote

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

The error InstructionFallbackNotFound is usually thrown by Anchor when the on-chain program cannot find the correct function to be called on the on-chain program. For Anchor the entrypoint method is ...
chalda's user avatar
  • 752
2 votes

Error:Deploying program failed transaction simulation failed: Error processing Instruction 0: account data too small for instruction [3 log messages]

You will need to extend your program size, if you made changes to it. This is possible from the CLI version 1.18 > To fix this run solana program extend PROGRAM_ADDRESS_HERE 20000 -u d -k ~/....
Jimii's user avatar
  • 1,934
2 votes
Accepted

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

The instructions are passed in order from left to right. So either you change the order of your parameters in the guess instruction or you write your instruction macro like this: #[instruction(dummy: ...
brimigs's user avatar
  • 166
0 votes

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

If you are using Anchor, you can get your program ID from the accounts context using ctx.program_id For native programs you have to pass in the program ID, which you can in your process_instruction ...
Jimii's user avatar
  • 1,934
0 votes
Accepted

Mutate account data of a program by another program

Only the program that owns an account can modify it. So in this case, you want receiver_program to modify the data in an account owned by sender_program, which is not possible. If DataAccount has an ...
Jon C's user avatar
  • 14.1k
1 vote

Mainnet contract deployment hangs

The above answer is right. Let me share an example. This is the best cmd I've seen for deploying contracts on mainnet. solana program deploy --program-id /home/odmin/projects/solana-betting-contract/...
Talented blockchain developer's user avatar
1 vote
Accepted

Error running anchor test: Unable to get latest blockhash

You might be getting rate-limited. Try requesting the airdrop using the airdrop instead, of each time before the tests run. Other possible things to try. Check your local solana config and confirm ...
Jimii's user avatar
  • 1,934
0 votes

Error: memory allocation failed, out of memory [CPI vs invoke_signed]

Modifying the structure of the accounts can help. Wrapping some accounts in Box might resolve the issue by reducing the stack memory used to store the data. To modify the existing function to use Box, ...
RAprogramm's user avatar
0 votes

Anchor CI/CD: Issues with Program Upgrade and Keypair Management

Yes, you understand correctly that the problem is related to updating the program in the CI/CD pipeline. The main issue is that every time anchor build is run in the CI/CD pipeline, a new keypair is ...
RAprogramm's user avatar
0 votes

in tweetnacl-rust Is there a way to Verify(detached_verify) signature on contract side in rust?

Unfortunately, you can't call the ed25519 program directly from your smart-contract. You need to include an instruction to the program at the toplevel, ie: let privkey = ed25519_dalek::Keypair:...
Jon C's user avatar
  • 14.1k
0 votes

What's the simplest way to implement a raffle on-chain?

ORAO has a very fast and cheap VRF available for Solana too. The SDK is on https://github.com/orao-network/solana-vrf and there is a nice Solana Program integration example in the form of an on-chain ...
oraodev's user avatar
0 votes

Resolve error i want to import " instruction as token_instruction,"

Try renaming it to mpl_token_intruction. Use mpl_token_metadata::instruction as mpl_token_instruction; Ref https://docs.rs/mpl-token-metadata/latest/mpl_token_metadata/
Jimii's user avatar
  • 1,934
1 vote
Accepted

How do I allow two different signers to modify data in a PDA?

0x1 error means that you have insufficient funds. Can you try airdropping yourself some SOL to the signer and updater accounts
Jimii's user avatar
  • 1,934
1 vote
Accepted

Tx Reverting Even If Internal CPI Fails

Way back when, in 2020, it was possible to catch errors during CPI, which is why invoke_signed returns a Result type. Due to the cost of handling reverting changes to accounts during CPI, though, that ...
Jon C's user avatar
  • 14.1k
1 vote
Accepted

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

The documentation says: Interface: Type validating that the account is one of a set of given Programs This just means that the given account is one of a set. For example, if your program can use ...
Jon C's user avatar
  • 14.1k
1 vote
Accepted

Error: failed to get recent blockhash: TypeError: fetch failed, but "connection.getLatestBlockhash()" works

I did not declare provider at the start, you can do this by anchor.setProvider(anchor.AnchorProvider.env());
Rishabh Jamwal's user avatar
0 votes

Error: failed to get recent blockhash: TypeError: fetch failed, but "connection.getLatestBlockhash()" works

Try using a new RPC provider like Helius for your connection string.
Jimii's user avatar
  • 1,934
0 votes
Accepted

Problem with associated token account of a mint account which initialized using Token2022

When deriving an ATA for token-2022, you also need to provide the token-2022 program id. Try doing: const associatedTokenAccount = await getAssociatedTokenAddress( mintKeypair.publicKey, payer....
Jon C's user avatar
  • 14.1k
0 votes

How can I make multisig DAO in anchor?

Take a look at the TribecaHQ programs, which are Anchor programs to perform DAO operations: https://github.com/TribecaHQ/tribeca
Jon C's user avatar
  • 14.1k
0 votes

How to Display Custom Balance of an SPL-Token without Associated Token Account?

If you're writing a custom token program, why not just store the correct balance on the ATA instead of the other PDA you've designed? The ATA is just a PDA too!
Jon C's user avatar
  • 14.1k
1 vote
Accepted

Check information on a staking account in a smart contract

It looks like anchor includes a StakeAccount type at https://github.com/coral-xyz/anchor/blob/460a16171a715671f77ead5629391c0466366c08/spl/src/stake.rs#L131 Feel free to use it as a type in your ...
Jon C's user avatar
  • 14.1k
0 votes
Accepted

Error: failed to get recent blockhash: TypeError: fetch failed when running anchor test

You have probably gotten your IP blacklisted. Give it a few days / switch to a new provider. When I faced this error, I switched my provider/connection string to Helius, since program deployments ...
Jimii's user avatar
  • 1,934
0 votes

React Frontend not working right with Anchor and localnet deployed Solana Program which passes Anchor Test

I have been trying the same using Phantom wallet with Solana localnet and anchor with no luck. Deployed to Devnet and that works. Following...
Arek S's user avatar
  • 101
0 votes

React Frontend not working right with Anchor and localnet deployed Solana Program which passes Anchor Test

Can you try entering my_account or MyAccount instead of myAccount? I've previously faced this issue where types were telling me to enter myAccount, but in reality, I had to enter my_account with // @...
Syed Aabis Akhtar's user avatar
2 votes

Mainnet contract deployment hangs

Use solana program deploy ./target/deploy/<program-name>.so with the following flags --use-rpc if you have a custom RPC URL (solana config set -u <url>) --with-compute-unit-price <...
Joey Meere's user avatar
1 vote
Accepted

Core Assets Validations

core assets, do have the concept of associated token accounts. It's a single program, the core program that handles everything, with the help of plugins. As such the old typed Metadata program ...
Jimii's user avatar
  • 1,934
1 vote

Anchor Build Error

I'm answering my own question: it looks like i had installed anchor 2 different ways. one was with homebrew. after i did brew uninstall, and reinstalled it with rustup, it seems to be working. i've ...
Boris Gotz's user avatar
0 votes
Accepted

Can't pass mpl token metadata CPI in anchor solana

The program-derived addresses for the metaplex program are based on the metaplex program id, and not yours, so you'll need to do something like: const [metadata] = anchor.web3.PublicKey....
Jon C's user avatar
  • 14.1k
2 votes

Revoke Mint authority in Anchor

Use the set_authority instruction. Then specify MintTokens as the authority type, and None as the new_authority
john's user avatar
  • 7,335
0 votes

Revoke Mint authority in Anchor

I was started learning rust and anchor framework try the below steps hope it will solve your problem Define a structure (e.g., Revoke) that includes the accounts needed for the revocation, such as the ...
SolNoob's user avatar
  • 11
0 votes

Error: missing field `discriminator` at line 28 column 5

If you are following the Solang getting started guide, use anchor version 0.28.0 Anchor "avm" installation instructions: https://book.anchor-lang.com/getting_started/installation.html ...
umarsa's user avatar
  • 1
1 vote

Error: The declared program id does not match the actual program id

I was facing the same issue when running anchor test. I tried anchor clean and changing the pubkey in the declare_id macro to match the one in target/deploy/[my_program_name].json, but this didn't ...
Ahri's user avatar
  • 3,365
0 votes

Stack offset error for anchor build

Try cargo clean Next, try again with cargo build-bpf GL
Nuker's user avatar
  • 1
2 votes
Accepted

Anchor error while running test

Your program uses authority.key() as a seed for both pdas However, when you derive the pdas, you use deployKeypair.publicKey for one and userKeypair.publicKey for the second one. Try using userKeypair....
john's user avatar
  • 7,335
4 votes
Accepted

Why is my system trying to build a newer solana-program crate than the one I have installed?

cargo, the Rust package manager, uses Semantic Versioning (SemVer) when deciding which version of the dependency to install. My system has 1.18.5 - where is '1.18.12' coming from? There is (almost) ...
acheron's user avatar
  • 2,521
0 votes

Limit what programs can call my anchor program via CPI

I don't know if Anchor provides an easy way to do this, but you can require a "signature" by a PDA from one of the allowed programs. If a PDA is marked as a signer, then the instruction had ...
Jon C's user avatar
  • 14.1k
1 vote

Issue while compiling the code | Using Anchor framework

Your error is arising from the AddCertificateRecord Accounts context. As the name suggest, the struct expect you to pass in accounts. You could pass the certificate informations fields as arguments ...
Jimii's user avatar
  • 1,934
3 votes

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

You can use remaining_accounts to pass in an arbitrary number of unchecked accounts, up to the transaction size limit. In the instruction you can access the accounts using ctx.remaining_accounts.iter()...
john's user avatar
  • 7,335
0 votes

Can't pass mpl token metadata CPI in anchor solana

The master edition seeds are ["metadata", ProgramID, mint, "edition"] whereas you are passing in "master" as the first seed.
kwelliott's user avatar
  • 514
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 ...
Jonas H.'s user avatar
  • 5,477
3 votes
Accepted

Relational PDA design through seeds

You could achieve this by including the user's public key in the PDA. First include user information in the data structures: pub struct Task { pub creator: Pubkey, pub id: u64, pub count: ...
brimigs's user avatar
  • 166
1 vote
Accepted

Could not find `pda` and `state` in `mpl_token_metadata`

These imports are for older versions From the latest version import them like this use mpl_token_metadata::accounts::{ MasterEdition, Metadata as MetadataAccount }; usage #[account( mut, ...
Jimii's user avatar
  • 1,934
0 votes

Anchor build says "cannot be built because it requires rustc 1.68.0 or newer" but I have a newer rustc installed

cargo install --force anchor-cli
Rahul Prasad's user avatar
1 vote

How to determine who can change data on a PDA?

There are some issues with the client code you shared, This part here sets your local wallet as the signer, and calling your instruction with .rpc will use this wallet to sign the transaction being ...
Jimii's user avatar
  • 1,934
0 votes

Issue While Connecting to Frontend with Anchor Backend

Could you try replacing the last argument with an instance of an anchor provider? provider initialization might looks something like this on an anchor project anchor.AnchorProvider.env().wallet as ...
Jimii's user avatar
  • 1,934
1 vote

Type 'SolanaNftAnchor' is missing the following properties from type 'Idl': address, metadata

As per this answer, it's because the IDL spec was rewritten with the 0.0.30 release and it's incompatible with previous versions of anchor. Please update your anchor TS client version to 0.0.29 "@...
Jimii's user avatar
  • 1,934
0 votes

How resolve "cannot find value `collection_mint` in this scope" for struct InitNFT / cNft & Anchor

After some research on the Anchor discord server, I find this solution, it look like a problem with the 0.30.0 version, Try to add this line on your Anchor.toml: [features] resolution = false seeds = ...
Fulum's user avatar
  • 11

Top 50 recent answers are included