Questions tagged [solana-program]
The solana-program tag has no usage guidance.
507
questions
0
votes
0
answers
11
views
Solana program tests are not running in isolated environment
I am running tests with cargo test-sbf.
We have a Global Program State that needs to be created only once the lifetime of program.
All the program tests are isolated that means I have to do it in all ...
0
votes
0
answers
16
views
Transaction Signature verification failed
I'm getting a Signature verification failed error from nowhere before this it was working 100% fine.
const UserStakeAccount = new PublicKey(stakeAccount);
const { vaultAccount } = await ...
1
vote
1
answer
36
views
how to do basic CPI another program from our program?
I've read solana and anchor's documentation on doing CPI, but still don't really understand.
what is the basis that must be understood when doing CPI program?
for example I want to call function ...
1
vote
1
answer
21
views
Deploy solana program on QuickNode?
I am noob!
I deployed my program on mainnet-beta but it didn't work and got 403 error. I did some research and found out that I needed to run my program on RPC server and I was referred to Quicknode.
...
0
votes
0
answers
24
views
Solders Solana transactions for Python from_bytes
I am just starting to learn how to work with crypto so I'm sorry for the basic questions, just trying to get an understanding. I am trying to write a function to complete a send transaction using ...
1
vote
1
answer
20
views
transaction.serialize is not a function
I use:
**await metaplex.connection.sendTransaction(signedTxs)**
but have this error:
**transaction.serialize is not a function at StandardWalletAdapter.sendTransaction**
do you know how to fix it?
2
votes
1
answer
33
views
Solana approve via signature
I wonder if there's a mechanism of transferring assets with receiver fee payment. Something like permit functions in solidity language?
Is it possible to copy this approach with PDAs? Share some ...
2
votes
3
answers
62
views
Transfer Solana using Solders for Python
I am still new to this and have been trying to figure this out for some time now so any help you can offer would really be greatly appreciated.
I see quite a bit of literature and tutorials on how to ...
2
votes
1
answer
27
views
On-chain program security related question (non-anchor)
What checks or kind of security should I implement if I'm developing an on-chain program without using Anchor-lang?
0
votes
0
answers
23
views
Random number generator(RNG) on Solana program [duplicate]
I'd like to know the way to get a lot of random numbers in a function on Solana Rust program. I know the way to get random number in a function but not sure if it works to get multiple numbers.
2
votes
1
answer
26
views
Is there a typescript schema/idl for the token program instructions?
Good morning, trying to decode data from the last instruction of this transaction which is a setAuthority instruction.
My main problem is that i can't get the newAuthority address from the data, since ...
0
votes
0
answers
14
views
How would someone obtain a list of all current solana public nodes?
How would I be able to scrape a list of all public nodes, or is there a place that reguarlly updates and posts these?
1
vote
1
answer
15
views
Does anyone have a coding standard documentation for Rust programming on Solana?
I have written smart contract in Rust using Anchor framework on Solana blockchain. I need to make sure that I'm following all the right coding standards. So if anyone happens to have a coding standard ...
0
votes
1
answer
19
views
How to get token account data from within the on-chain program?
I'm using get_associated_token_address to get a token account but how to find out if it is valid or not? Any help please?
let payer_associated_token_account = get_associated_token_address(
...
0
votes
0
answers
17
views
Cross-program invocation: Signer privilege escalated
Thanks ATON for viewing the problem, I need URGENT help on this if possible.
I have created a PDA and used the PDA to freeze an NFT.
#[account(init,
payer=bidder,
seeds = [
bidder.key()....
2
votes
1
answer
19
views
constructs a new Loader from account. using AccountLoader from anchor_lang crate
i referred this https://docs.rs/anchor-lang/latest/anchor_lang/accounts/account_loader/struct.AccountLoader.html for Constructs a new Loader from account.
use anchor_lang::prelude::*;
use whirlpools::...
1
vote
1
answer
20
views
Using HashMap in Solana Rust Contract
I have found that it is not possible to use HashMap, but BtreeStorage is possible. I have already tried to use those. But I am getting errors.
I was trying to use this:
https://github.com/hashblock/...
0
votes
0
answers
28
views
How to sign dApp request?
Here, I am connecting raydium with Wallet Connect V2 and trying to Sign and send the transaction of the below request but, getting transaction error like SolanaError(code=-32602, message=invalid ...
2
votes
1
answer
23
views
Why can't I use a future blockhash for on-chain randomness?
To my knowledge, Blockhashes are determined by the hash of numerous things involving the instruction data of the transactions involved in the block, and the previous hashes.
it is practically ...
0
votes
0
answers
14
views
Access violation in unknown section at address 0x0
in this log, my logic is completed in instruction but somehow Program failed to complete. Can anyone help me here? why program is failing.
logs: [
'Program <my_program> invoke [1]',
'...
0
votes
1
answer
17
views
Is it possible to send a transaction with phantom to an on-chain program with the purpose of modifying that program's data?
const [programDataAddress] = PublicKey.findProgramAddressSync(
[programId.toBuffer()],
BPF_LOADER_UPGRADEABLE_ID
);
const programDataAccountMeta: AccountMeta = {
pubkey: programDataAddress,
...
1
vote
1
answer
27
views
How to update account loaded with AccountInfo
For some migration purpose I need to load a pda account with AccountInfo , reallocate and update the fields. I am able to make other parts right got stuck updating/modifying account data. Transaction ...
0
votes
2
answers
31
views
Error processing Instruction 0: An account required by the instruction is missing
I am creating a game account, then transferring a certain amount from the user to this account. Afterwards, I determine the winner randomly by the system or the user, and transfer the total amount to ...
4
votes
1
answer
34
views
How to Listen to Account Changes in a Solana program?
For Example there is a change in a account in a program how do i listen to that changes to do something. I tried using webhooks but they listen to transaction's and the account involved in that tx ...
0
votes
1
answer
115
views
Anchor: Failed transaction: Transaction simulation failed: This program may not be used for executing instructions
When I try to run this simple "hello world" example, I get this error:
$ anchor test
Error: Function _ZN14solana_program4vote5state9VoteState11deserialize17h6501cbf018769324E Stack offset ...
0
votes
0
answers
13
views
How can i implement wormhole in anchor code
i want to build a fn to transfer token cross chain (between solana and EVM) i find wormhole to do that but i only found code instructions to call from client. Can I do it from smart contract (anchor)?....
0
votes
1
answer
11
views
Visibility argument in a contract call
On block explorers I see transactions and the program functions that have been called, but not the arguments in this function call. Are these traceable somewhere? Or are they only visible to the RPC ...
3
votes
1
answer
30
views
How to find which version of rust should be used with a given solana-program / solana-cli version
Where does solana keep track of the latest version of rust that can be used with a given version of solana-program or solana-cli?
I've looked in this file before but the specific version number has ...
1
vote
1
answer
39
views
unable to get token account balance from AccountInfo
can anyone help me over here, please.
use solana_program::account_info::AccountInfo;
use spl_token::state::Account;
fn get_token_account_data(account_info: &AccountInfo) -> Result<Account, ...
0
votes
2
answers
52
views
How to define a variable to a public key in anchor? [duplicate]
I want to hardcode a public key in my anchor Solana program and then compare it with the public keys passed to the functions of the program. Can someone please tell me how can I declare a variable ...
1
vote
0
answers
17
views
Topic support when subscribing to Solana programs events
Anchor events are fairly easy to use in JS and Rust, nonetheless the current integration many times forces us to receive hundreds or thousands of irrelevant emitted program events. Is there a way to ...
0
votes
1
answer
22
views
Can we change the owner of a Solana account?
I have a solana account created by a solana program deployed on the devnet. Is it possible to change the owner of the account? If yes then can you please tell how to do it?
0
votes
1
answer
27
views
Can solana accounts be made immutable?
I have recently started learning about solana development and realised that solana accounts created by solana programs are mutable. Is there any way we can make them immutable? Also can you please ...
0
votes
1
answer
43
views
Error: AnchorError: AnchorError caused by account: base_account. Error Code: AccountNotInitialized
I wrote a Solana Program with two functions, one for initialization of an account and second to upload data to the account. While testing on localhost it was working fine, but when I uploaded it to ...
3
votes
2
answers
27
views
Deploy regular solana (not anchor) on mainnet
I'm looking to deploy a regular solana program written in Rust (not anchor) on mainnet. For some reason I can't rewrite it using anchor solana. I have searched online and all failed. Does anyone know ...
0
votes
1
answer
31
views
NotEnoughKeys when deploying a txn (ReactJs/Typescript/Solana)
I have this code to transfer sol via a contract and via web3 in ReactJS -
const transferSol = async () => {
if (!publicKey) throw new WalletNotConnectedError();
const ...
0
votes
1
answer
29
views
How to define constants in Anchor
Is there some special approach for defining constants in Anchor? I tried it normally just before the program ID:
pub const MY_CONST: &'static str = "some example str";
declare_id!("...
1
vote
1
answer
25
views
So when i Initialize i get a program error, It worked when i just created it without a txn confirmation
I tested the code without the sendandconfirmtxn and it worked, but then after deploying devnet it stopped working.
this is my program
#[program]
pub mod solotesting2 {
use super::*;
pub fn ...
2
votes
1
answer
59
views
How to transfer SOL in a contract using the playground?
I tried a few variations and I cannot get the instruction to work or be defined correctly. I have this client code and I welcome suggestions about how to code the instruction variable -
Error -
...
1
vote
1
answer
33
views
How to define fixed variables in Anchor programs
Is it possible to define a variable within the Anchor.toml file and then use it during run time inside the anchor program? I couldn't find how in the docs.
I guess an alternative could be defining the ...
2
votes
1
answer
106
views
Can Solana Accounts be accessed by any Solana Program using its address?
If I have a deployed Solana Program which creates some Solana accounts for storing data in it. Can these Solana accounts be accessed by any other Solana program using the account addresses? I am ...
1
vote
1
answer
23
views
Solana program test coverage
Is there any tool to measure test coverage of test written in rust with solana-program-test crate?
2
votes
2
answers
66
views
InstructionFallbackNotFound. Error Number: 101. Error Message: Fallback functions are not supported
Have a question related to custom program development. I've testing this program
pub mod fluxtility {
use super::*;
pub fn buy_ticket(ctx: Context<Initialize>, lamports: u64) -> ...
1
vote
0
answers
30
views
How to call another instruction from the same Anchor program (No CPI) [duplicate]
Is there a way to invoke an instruction within the same program? just for the sake of code reusability, I know we can achieve this easily with CPI when invoking different programs instructions, but I ...
1
vote
1
answer
19
views
Cant airdrop solana token
Noob question:
I get this error when trying to run an anchor test as well,
NOTE: Im on m1 chip
1
vote
3
answers
219
views
solana-program fails to compile with "experimental" and "unstable" errors
I have been trying to make solana work for the last few days.
Now I seem to have hit a wall, as I can't find anything about this online.
I believe I have the latest version of everything and I have ...
3
votes
1
answer
38
views
What is first 8 bytes of anchor generated instruction data? [duplicate]
I am passing two u32 argument to the instruction. They are appearing at the end but not sure about the first 8 bytes of the instruction data.Another question maybe similar to this how anchor ...
1
vote
2
answers
77
views
How do you deal with a changing account state?
Let us suppose that you want to update an account state to include a new field.
pub struct MyState {
pub a: u8,
pub new_field: u8
}
This means that fetching and decoding the old accounts prior to ...
3
votes
1
answer
45
views
Difference between using ctx.bumps and passing in the bump
There is two ways of ensuring the bump
First: Client side passed as parameter to be stored program side
const [pubkey, bump] = findProgramAddress()
program.methods.myMethod({bump})
Second: Solana ...
2
votes
1
answer
39
views
Traces in Solana
I'm looking to create a data pipeline that gets traces (both value transfers and contract executions like on the EVM) but, I can't find the equivalent to it on Solana's VM.
What is the equivalent to ...