Skip to main content
11 votes
Accepted

error: package `winnow v0.4.4` cannot be built because it requires rustc 1.64.0 or newer, while the currently active rustc version is 1.62.0-dev

The error message is misleading because the error actually results from the version of rustc that ships with solana and not your system's rustc version. See https://github.com/solana-labs/solana/...
acheron's user avatar
  • 2,571
6 votes
Accepted

On calling ctx.bumps.get("mint_account"), failing with error method `get` not found for this struct

If you're using anchor-lang 0.29 (check the Cargo.toml file), the syntax for getting the bump has been updated. Try using: ctx.bumps.mint_account
john's user avatar
  • 7,405
5 votes

Getting error while minting token to an account "Transaction simulation failed: Error processing Instruction 0: invalid account data for instruction"

Your program expects the token account to be initialized already. Are you initializing it before calling the instruction? If not then it should return the invalid account data error like it is doing ...
0xShuk's user avatar
  • 1,929
4 votes

Looking for implementation example of anchor_spl::token::initialize_account

The initialize_account function is to create a new Token Account. The account in the struct is the Token Account that is being initialized in the instruction Here's a solpg link for reference ...
john's user avatar
  • 7,405
4 votes
Accepted

Is it possible to get the number of decimals for an SPL token in an anchor program?

Yes, it is possible. Imagine you have a mint x: pub mint_x: InterfaceAccount<'info, Mint> You can get the decimals by reading the following parameter: mint_x.decimals
ASCorreia's user avatar
  • 263
4 votes
Accepted

How to increase the PDA size after deployment with anchor framework

You could use the realloc constraint on anchor too. This is a duplicate of this question the code snippet from the question #[derive(Accounts)] pub struct Example { #[account(mut)] pub payer: ...
Jimii's user avatar
  • 3,020
3 votes
Accepted

Is it possible for an anchor smart contract to detect which network it is running on

The only way to know which network you're on is to through the different genesis hashes: https://docs.solana.com/api/http#getgenesishash Since you can't access that on-chain, you'll need to manage ...
Jon C's user avatar
  • 15.1k
3 votes

Getting insufficient balance error while trying 'anchor deploy' , but I have enough fund in my wallet. How to solve this?

Make sure the [provider] section in your Anchor.toml file specifies cluster = "Localnet". If it doesn't, Anchor might be trying to deploy against a different cluster that isn't localnet ...
Ademola's user avatar
  • 3,833
3 votes

Looking for implementation example of anchor_spl::token::initialize_account

Here's a Solpg example for how to create an associated token account in Anchor using init_if_needed https://beta.solpg.io/6317c4d1bb7e0b5f4ca6dfa2 use anchor_lang::prelude::*; use anchor_spl::...
john's user avatar
  • 7,405
3 votes

Deriving an associated token account address

Here's an example in Anchor: use spl_associated_token_account::get_associated_token_address; let token_address = get_associated_token_address( &owner_pubkey, &some_mint, ); Src: ...
AMilz's user avatar
  • 1,536
3 votes

Getting insufficient balance error while trying 'anchor deploy' , but I have enough fund in my wallet. How to solve this?

You might not be aligned correctly with what your local solana config is setup as. Could you open your terminal and type in "solana config get" and see what it says? The problem here is ...
jajaMundo's user avatar
3 votes

error: package `winnow v0.4.4` cannot be built because it requires rustc 1.64.0 or newer, while the currently active rustc version is 1.62.0-dev

I just added winnow="0.4.1" in dependency section of Cargo.toml file and it worked. Initially I have added anchor-spl = { git = "https://github.com/coral-xyz/anchor" } in place of ...
Panchal Vedant's user avatar
3 votes

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

To check if a PDA is initialized, or check it against an account being passed into the program, the following can be done (if using anchor) Import Pubkey: use anchor_lang::solana_program::pubkey::...
Joey Meere's user avatar
  • 1,139
3 votes
Accepted

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

try to rename the JSON file in target/deploy. Then the deploy script should create a new keypair to deploy your program, and you should have a new program address
Effe2's user avatar
  • 1,178
3 votes

Transfer Hook - How to get destination ATA owner public key

The 3rd account (index 2) labeled destination_token is the recipient token account from the initial token transfer. You should be able to access the address of the owner stored on the token account to ...
john's user avatar
  • 7,405
2 votes
Accepted

need some example of spl token or sol transfer

This is a common misconception when first starting with Solana development. Anytime you're dealing with an account whose state you're trying to read or write, what you want is not the pubkey, but the ...
HelmetFace's user avatar
  • 1,747
2 votes

error[E0658]: destructuring assignments are unstable, why?

I had the same problem. I updated my Solana install using the command solana-install update, per this issue on github: https://github.com/coral-xyz/anchor/issues/2133.
Bass581's user avatar
  • 21
2 votes
Accepted

Lifetime error while transferring custom token to dynamic list of accounts

Try and explicitly align the function and arguments lifetimes. https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html pub fn transfer_token<'a>( ctx: Context<TransferToken<'a>, ...
Ohad Dahan's user avatar
2 votes

error of "Cross-program invocation with unauthorized signer or writable account"

An associated token account by definition already uses its own set of seeds. Try removing the seeds constraint and see if that helps. And update to using the correct associated token constraints: #[...
Henry E's user avatar
  • 3,050
2 votes
Accepted

Get NFT's owner on chain

An NFT is essentially a token and can be treated as such. If you're using anchor, you can simply use the owner of the account holding the token ctx.accounts.nft_token_account.owner that's the owner ...
iMEF's user avatar
  • 336
2 votes
Accepted

anchor-spl library 0.25.0 breaks on build

The build error tells you that solana-program-test = "=1.10.38" requires spl-associated-token-account 1.1.1, but anchor requires 1.0.5, so you'll have to drop solana-program-test to a lower ...
Jon C's user avatar
  • 15.1k
2 votes

Token Rewards Calculation and Distribution

If you have the data on chain you can for example use a tool like clockwork.xyz to trigger the token distribution automatically every two weeks using a cron notation trigger. They also have a token ...
Jonas H.'s user avatar
  • 5,727
2 votes

How to fix Borsh serialize error on Anchor 0.28 when publishing crates

Try these constraints anchor-lang = { version = "0.28.0", features = ["init-if-needed"] } anchor-spl = { version = "0.28.0", features = ["metadata"] } solana-...
Cloakd's user avatar
  • 421
2 votes
Accepted

Getting error while minting token to an account "Transaction simulation failed: Error processing Instruction 0: invalid account data for instruction"

It looks like the address of your mint account is a pda. #[account( mut, seeds = [b"mint"], bump, mint::authority = authority, mint::...
john's user avatar
  • 7,405
2 votes
Accepted

Temporarily lock SPL token transfer for all ATAs

In my opinion you could achieve your goal without using the Token2022 Program but just by using the Normal SPL Token with the following functions: Delegate the ATA of the token you want to lock to a ...
LEO's user avatar
  • 114
2 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. ...
Jonas H.'s user avatar
  • 5,727
2 votes

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

This is a total shot in the dark, but 0xc might refer to InvalidInstruction from the SPL token program: https://github.com/solana-labs/solana-program-library/blob/...
Jon C's user avatar
  • 15.1k
2 votes

failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x5

If this is an error comming from the token_metadata_program then my way is to search for the program and checking the error set. For that the metadata program can be found at https://github.com/...
chalda's user avatar
  • 1,062
1 vote

How to transfer large number of SPL tokens?

The maximum amount of tokens for an SPL token mint is u64::MAX. The supply is stored as a u64 at https://github.com/solana-labs/solana-program-library/blob/177a6c94d751e49be0e299b0155823195a21e7fe/...
Jon C's user avatar
  • 15.1k
1 vote

How to implement a Buying NFT feature on solana program?

It looks like your instruction requires signing by an owner_authority and buyer_authority. You can add addition signers by using .signers([]) let tx = await program.methods .buyNft() ...
john's user avatar
  • 7,405

Only top scored, non community-wiki answers of a minimum length are eligible