Skip to main content
3 votes

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

The two types aren't inherently different under the hood. UncheckedAccount simply skips the validation checks a normal included account would go through in an Anchor instruction. You can attempt to ...
Joey Meere's user avatar
  • 1,425
3 votes

Interoperability/Bridging with Solana and other chains

If you're looking for interoperability/bridging options, you can look at the following: Wormhole: https://wormhole.com/ DeBridge: https://debridge.finance/
Joey Meere's user avatar
  • 1,425
3 votes

Why does TypeScript throw a warning for ResolvedAccounts for my PDA in my Anchor tests?

This is because all PDAs resolve automatically in Anchor 0.30. The client does not need to know anything about the resolvable accounts, thus you can safely remove the web3.PublicKey....
acheron's user avatar
  • 2,591
3 votes
Accepted

Escrow program help

You violated borrow checker rules. You borrow the Escrow account as a mutable variable here let escrow: &mut Account<Escrow> = &mut ctx.accounts.escrow; but try to use it as an immutable ...
Jimii's user avatar
  • 3,520
2 votes
Accepted

How to decode account data using Rust?

mpl_token_metadata::accounts::Metadata has a function from_bytes which serializes the bytes into a Metadata struct: let meta: Metadata = Metadata::from_bytes(&account.data).unwrap();
lifeInspection's user avatar
2 votes
Accepted

How can I initialize an SPL token mint using anchor_client?

I believe, or as I understand, there is no reason to construct the instructions via anchor_client. The Anchor client generates the client abstractions for the Anchor program so that instruction-...
chalda's user avatar
  • 1,252
2 votes
Accepted

"anchor build" wont generate my "../target/types/program_name" file

for anchor 30 to generate your IDL you need to add the build idl feature into your Cargo.toml: idl-build = ["anchor-lang/idl-build"] And double check you don't have a compiler error in your ...
Jonas H.'s user avatar
  • 5,777
1 vote
Accepted

Request solana airdrop in rust/anchor

Nevermind, figured it out: /// Replace with devnet or whichever cluster you're currently on let rpc = RpcClient::new(Cluster::Localnet.url()); let sig = rpc.request_airdrop(pubkey, lamports).unwrap();
Ahri's user avatar
  • 4,167
1 vote

Reference to mint is not recognized in Struct creation while trying to create an NFT in Anchor

This tutorial uses an outdated version of mpl_token_metadata. Switch to a Metaplex version >0.4.0 e.g mpl-token-metadata = "4.1.2" Update your Solana version to 1.18.8. You'll face some ...
Jimii's user avatar
  • 3,520
1 vote

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

The error means invalid mint as you can see here: https://github.com/solana-labs/solana-program-library/blob/master/token/program/src/error.rs So im not sure how you created the USDC mint, but maybe ...
Jonas H.'s user avatar
  • 5,777
1 vote
Accepted

Using `onAccountChange` in Rust

Figured it out: let listener_client = PubsubClient::new(<WSS URL>).await.unwrap(); // Can add a config instead of None here, but None for simplicity let (stream, shutdown_handle) = ...
Ahri's user avatar
  • 4,167
1 vote
Accepted

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

The reason why CreateToken is probably because you are using different seeds. The mint seeds will be your program ID + your mint seeds const [mintAccount, mintAccountBum] = anchor....
Jimii's user avatar
  • 3,520
1 vote

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

Not sure if I fully understand your question, but you want to convert a typed account to an untyped account? Since both AccountInfo and UncheckedAccount are basically just AccountInfo types, using ....
Jimii's user avatar
  • 3,520
1 vote

Error Number: 2006. Error Message: A seeds constraint was violated

You migh be deriving the lottery address incorrectly, Try this and check whether the tests pass const [lotteryPda, lotteryBump] = PublicKey.findProgramAddressSync( [Buffer.from(lotterySeed), ...
Jimii's user avatar
  • 3,520
1 vote

'invalid account data' error when using Immutable Owner extension and Non-transferable extensions together

The provided account length won't be enough, because you also need to include space for the NonTransferableAccount extension. I think it should work if you just change the line creating accountLen to: ...
Jon C's user avatar
  • 15.9k
1 vote

Cost of creating Spl-Token is higher when I use my own rust code than using generator tools

Usually, the cost for creating the token consists of rent (https://solana.com/docs/core/fees#rent) needed to be deposited to create Solana accounts. On removing accounts from Solana blockchain the ...
chalda's user avatar
  • 1,252
1 vote
Accepted

Transaction failed to sanitize accounts offsets correctly

The program_id was not correct!
xyzkal's user avatar
  • 31
1 vote

"failed: An account required by the instruction is missing" transfer within contract

The error you are encountering means you are trying to you are trying to transfer to an account you haven't specified on your client side. Double-check to make sure that the user_pda and user_account ...
Jimii's user avatar
  • 3,520
1 vote

How to resolve 'Collection Must Be a Unique Master Edition v2' error?

It has been confirmed that if the max_supply value is not set to 0 when creating a collection NFT, the 'Collection Must Be a Unique Master Edition v2' error occurs when attempting verification with ...
StarPJ's user avatar
  • 21
1 vote

How to resolve 'Collection Must Be a Unique Master Edition v2' error?

Check the master_edition address you are passing in. That might be causing it. To also simplify your work, Metaplex provides CPI IX builders so that you do not have to worry about account management. ...
Jimii's user avatar
  • 3,520
1 vote

Raydium swap with rust

Check out the Anchor CPI examples in this repo https://github.com/raydium-io/raydium-cpi-example
Jimii's user avatar
  • 3,520
1 vote

|RUST| link Error:1169 Solana Transaction Contract

The error says that a symbol is defined multiple times between two different libraries: = note: libspl_token-9c38dd82029194be.rlib(spl_token-9c38dd82029194be.spl_token.26961209c36bf507-cgu.0.rcgu.o) ...
Jon C's user avatar
  • 15.9k

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