Skip to main content
3 votes
Accepted

How to transfer tokens using transfer hook in Anchor

There might not be Anchor helpers yet to create the proper transfer with all the transfer hook accounts. In the meantime, you can use the onchain helpers that come with token-2022 at https://github....
Jon C's user avatar
  • 15.3k
3 votes

How can I generate a random number on Solana?

Depends on what you need the random numbers for. A little primer on blockchains is that they need to be deterministic and replayable, meaning we cannot achieve true randomness on-chain. For example, ...
Jimii's user avatar
  • 3,120
2 votes

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

The error suggests that you might be driving the PDA wrongly. Try removing the as_ref() method from your seeds since the b"" token, already converts the string slice to a byte sequence &[...
Jimii's user avatar
  • 3,120
2 votes

How to transfer tokens using transfer hook in Anchor

When a transfer hook program's execute instruction is invoked, all accounts from the initial transfer instruction are converted to readonly Although the error you're getting seems to be ...
john's user avatar
  • 7,445
2 votes
Accepted

How can I find out how much SOL I will need to deploy an anchor program?

It'll depend on the version of the tools used. In 1.18, with https://github.com/solana-labs/solana/pull/34730, there won't be any padding included, so you can just calculate based on the size of the ...
Jon C's user avatar
  • 15.3k
2 votes

How to find the collection address to which it belongs through the nftmint account? How to write it in the backend Anchor

If the mint address contains Metadata added to it through the Metadata program, you can get this from the metadata account The Metadata Account contains an optional Collection field which contains the ...
Jimii's user avatar
  • 3,120
1 vote
Accepted

Fetching an account declared in `declare_program!` using anchor_client

Figured it out. We can do: declare_program!(my_program); use my_program::{ID, accounts::MyAccount}; let cl = Client::new_with_options( cluster, fee_payer, CommitmentConfig::confirmed(), );...
Ahri's user avatar
  • 3,920

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