All Questions
15 questions
4
votes
1
answer
146
views
Handle big vector containing ton of structs
I'm looking for a way to handle a big struct.
I want to understand how to create an account storing more than 10_000 structs inside is possible.
Is there a simple way to do it? Or should I have to ...
0
votes
1
answer
51
views
"failed: An account required by the instruction is missing" transfer within contract
This is the entire source code of the smart contract
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint,
entrypoint::ProgramResult,
msg,
program_error:...
1
vote
1
answer
92
views
best way to convert `account_index` to address using rust rpc-client and JSON RPC response
When using the solana-rpc-client in Rust to retrieve a transaction, the output is EncodedTransactionWithStatusMeta.
The metadata includes the following struct:
pub struct UiTransactionTokenBalance {
...
0
votes
1
answer
45
views
Is it possible to set up an account to point to another account?
I'm making an anchor program where I would like to make a user ID easily retrievable with their Pk, sequential ID or username. one way I thought is to make a PK link account (in case the seed for the ...
1
vote
1
answer
108
views
Error: Invalid option while trying to fetch account data with anchor
I'm getting this error
Error: Invalid option endTime
at OptionLayout.decode (node_modules/@project-serum/borsh/src/index.ts:148:11)
at Structure.decode (node_modules/buffer-layout/lib/...
0
votes
1
answer
74
views
How to ensure unique u16 IDs for accounts?
I'm storing a vector of u16 user IDs. I decided not to store public keys in vector, which I can use as ids or get rid of ids completely instead, however public keys are 32 bytes and will have limited ...
0
votes
1
answer
193
views
Why we need to pass all that accounts into functions in native solana?
I am go through the solana course and I am not understand that basics of writing solana native programs. Why do we need to pass to the functions some AccountInfo slice? Where this adressess should ...
0
votes
2
answers
2k
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
45
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 ...
4
votes
1
answer
142
views
Why do we use lifetime parameter when we create an account struct?
This is an example of account struct in an anchor project.
#[derive(Accounts)]
pub struct Create<'info>{
#[account(init,payer=user,space=264)]
pub calculator:Account<'info,Calculator&...
2
votes
1
answer
1k
views
How to generate address out of a seed phrase and a derivation path for Solana and some tokens?
I know how to generate addresses out of a seed phrase and a derivation path in Ethereum. And I need to do the same thing for Solana too. However, I've done a research and barely found anything.
Also, ...
1
vote
2
answers
586
views
How to find the exact number of bytes to allocate for a Solana Account in Rust
I want to create wallet account via Rust program by using payer & mint account, in that case how to predict the number of bytes to allocate for the new account data so that I can pay less rent ?
...
1
vote
1
answer
97
views
Can I read information stored by a PDA without having to deserialize its byte array?
here is my on-chain code to create the PDA account
#[derive(Accounts)]
pub struct Initialize<'info> {
#[account(init, payer = user, space = 20 , seeds = [user.key().as_ref()], bump)]
...
1
vote
1
answer
417
views
What's the difference between Anchor Accounts and account attributes?
When looking at the docs it seems that both Accounts and account attributes are useful for account serialization, deserialization, and validation. Furthermore, Accounts seems to be a derive attribute ...
4
votes
3
answers
496
views
Program cannot deserialize borsch serialized instruction from typescript client
I am trying to write a client code in typescript for a contract written in vanilla rust. I am unable to serialize an instruction such that it can be deserialized by the program
#[derive(Debug, ...