Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 271
3 votes
Accepted

How to make sure the transaction fails

Can use: https://docs.rs/anchor-lang/latest/anchor_lang/macro.require_gte.html Pass it your custom error so it will be easy to understand why it failed in the transaction log.
Ohad Dahan's user avatar
3 votes
Accepted

How do you retrieve an account to read state?

You must pass the account to the program, you can't read from an account you didn't pass as an argument. The VM will fetch all these accounts and provide them to your program.
Ohad Dahan's user avatar
2 votes
Accepted

Anchor: Signing and paying for transactions to interact with program

If it's in the browser, use: const transaction = await this.program.methods .createMerchant() .accounts({ user: this.userPubKey, merchantAccount: merchantPDA, }) .transaction() And se …
Ohad Dahan's user avatar
2 votes

RPC CALL WITHOUT HAVING LAMPORTS

Most RPC calls are read hence you don't even sign them, so the RPC doesn't even know if you have lamports or not. I think it's only relevant for: https://solana-labs.github.io/solana-web3.js/classes/C …
Ohad Dahan's user avatar
2 votes

NFT batch transact

You can build a transaction with multiple instructions (createTransferCheckedInstruction) to move each token (up to the instruction limit). https://solanacookbook.com/references/token.html#how-to-tran …
Ohad Dahan's user avatar
1 vote

Sending SOL from account to PDA (or any other account) results in Error: Transaction simulat...

If you want to transfer SOL from a PDA , I found the following to be the most reliable method, from is a PDA. pub fn transfer_sol(from: &mut AccountInfo, to: &mut AccountInfo, amount: u64) -> Result<( …
Ohad Dahan's user avatar
1 vote
0 answers
67 views

RUSTFLAGS="-C instrument-coverage" with solana program [closed]

Trying to add check coverage, when using RUSTFLAGS="-C instrument-coverage" cargo build-bpf I'm getting: error: failed to run `rustc` to learn about target-specific information Caused by: process d …
Ohad Dahan's user avatar
1 vote
1 answer
132 views

solana zk program

I couldn't find any example of usage, I'm trying the following and getting Attempt to load a program that does not exist. This is trying the official Solana zk-program: https://github.com/solana-labs/ …
Ohad Dahan's user avatar
0 votes

Is randomness achievable on-chain?

Most of the coin-flip games you see use some form of off-chain random source (Oracle is just someone pushing into the chain something generated outside). There are ways to generate pseudo random numbe …
Ohad Dahan's user avatar
0 votes

How can I get all the account addresses owned by a program?

Please use GPA for that, keep in mind it's a very slow and expensive call. https://solana-labs.github.io/solana-web3.js/classes/Connection.html#getProgramAccounts
Ohad Dahan's user avatar
-1 votes

anchor deploy: Invalid Blockhash

Use a custom RPC , such as https://devnet.genesysgo.net the default public ones aren't suitable for that.
Ohad Dahan's user avatar