Skip to main content

Questions tagged [account]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
30 votes
6 answers
2k views

What is a Program Derived Address (PDA) exactly?

Is this an account or is it an address? Why do I need it? What problem or use case does it solve? Why can't I just use a regular account instead?
Dima Knivets's user avatar
9 votes
1 answer
684 views

How can I increase an existing account size?

ie. Initialize account with 255 byte space. Pay to double the space through anchor.
user2892730's user avatar
8 votes
1 answer
2k views

What is Anchor (8 bytes) discriminator

The question should be straightforward.
vicyyn's user avatar
  • 4,295
7 votes
2 answers
793 views

How to correctly read data from a Zero Copy account

I'm having trouble reading data in the client from a program with a zero copy account. I've defined the account as follows: #[account(zero_copy)] #[repr(packed)] pub struct EventQueue { header: ...
rumika howdie's user avatar
7 votes
1 answer
423 views

what is ledger space in solana?

from here On Solana, State Compression is the method of creating a "fingerprint" (or hash) of off-chain data and storing this fingerprint on-chain for secure verification. Effectively using ...
Yilmaz's user avatar
  • 1,264
6 votes
1 answer
492 views

How do I get historical AccountInfos at timestamp x, y, and z?

I would like to create transaction graphs for research purposes. To do this I need to obtain the data in the account at specific timestamps. What's the simplest way to do this?
amaz_ng's user avatar
  • 75
5 votes
2 answers
1k views

How much rent is needed to create a new account?

When creating a new account on Solana, how do I calculate the amount of rent (SOL) needed to pay for and create the account?
DonnySolana's user avatar
5 votes
1 answer
539 views

How to export all Solana accounts with positive balance?

Given access to Solana validator node and solana command, how to export a list of all account addresses with positive balance (at the latest block)? Preferably in CSV format.
kenorb's user avatar
  • 529
5 votes
1 answer
358 views

Whats the difference between a Signer and Accounts in Anchor? Where should they be used?

pub fn startstuffoff(ctx: Context<StartStuffOff>) -> Result<()> { let base_account = &mut ctx.accounts.base_account; base_account.total_gifs = 0; Ok(()) ...
Muhammad Shahrukh Azeem's user avatar
5 votes
1 answer
403 views

How to efficiently transfer NATIVE SOL to a program accepting WRAPPED SOL?

I am writing a program in which the accepted payment MUST be from a token account. Anchor context snippet here: pub struct Payment<'info> { #[account(mut)] pub buyer_token_account: ...
Burger Bob's user avatar
  • 1,506
5 votes
2 answers
254 views

How to pass an uninitialized PDA account to a CPI to initialize it without getting AccountNotInitialized error

I have ProgramA and ProgramB. ProgramA initializes an account using InstructionA. When ProgramB uses a CPI to call instructionA I'm getting AccountNotInitialized error. I'm using the following code: ...
cris.sol's user avatar
  • 292
5 votes
2 answers
2k views

How do I fix 'please minimize large stack variables' error while testing my anchor program?

I'm getting the following error using Anchor 0.25.0 Stack offset of 11792 exceeded max offset of 4096 by 7696 bytes, please minimize large stack variables initializing my accounts on local testing. I'...
AceGravity's user avatar
5 votes
1 answer
402 views

What is the recommended way to provision an instance of solana-test-validator with a set of accounts and mints?

I'm curious what the recommended way is to provision an instance of solana-test-validator with a 'known state', consisting of a few accounts and mints. We use this 'known state' in our local ...
beeman's user avatar
  • 1,062
5 votes
1 answer
174 views

How to read account data in non owner program

If I deploy a program P1 which initialises a new account A1 and update the rvalue to for instance 9 #[derive(Accounts)] pub struct Initialize<'info> { #[account(init, payer = signer, ...
Chester King's user avatar
5 votes
3 answers
659 views

how to fetch list of all pda accounts in frontend? like sale account instance to display in the market? or should i be fetching from token account?

i have a sale order account defined like this.. #[account] pub struct Order { pub creator: Pubkey, pub mint_key: Pubkey, pub memo: String, pub price: u64, pub bump: u8, } And this ...
Lobo1897's user avatar
  • 153
5 votes
1 answer
538 views

Why is it possible to initialise a program account to my wallet address, stopping me from signing anything in future?

This was an accidental discovery when playing with the Solana Playground, but it surprised me and feels like a bug. I'm wondering why it works this way. Example: https://beta.solpg.io/...
Callum M's user avatar
  • 3,775
4 votes
2 answers
2k views

Is there a way to estimate the transaction size?

Currently to get the size of a transaction I have to do the following const tx = new Transaction().add(...) const { blockhash } = await connection.getLatestBlockhash(); tx.recentBlockhash = blockhash; ...
lameren's user avatar
  • 173
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, ...
chinepun.sol's user avatar
4 votes
3 answers
2k views

Confusion between Token Account and Associated Token Account?

I am new to Solana dev. I am confused by the answers on StackExchange. The token mint holds information about a specific mint. An associated token account is an account linked to a user so the user ...
LAUR_NASA's user avatar
  • 193
4 votes
1 answer
295 views

What is the data size of a wallet account?

I want to calculate the minimum balance for Rent-except and have found code like this: const { Connection, clusterApiUrl, LAMPORTS_PER_SOL } = require('@solana/web3.js'); const connection = new ...
breeze wang's user avatar
4 votes
2 answers
246 views

Why do some token accounts own themselves?

I was under the impression that accounts owned by users owned a set of token accounts which each represent one distinct token that they own - meaning token accounts would only be owned by a user. For ...
xxl's user avatar
  • 43
4 votes
1 answer
85 views

Can you modify a non-PDA account's data when you know its private key [closed]

I am gathering some information about the advantages of PDA accounts over accounts that have private keys. While the obvious one is that there is the potential vulnerability that you can withdraw ...
Sebastian Dine's user avatar
4 votes
1 answer
436 views

How to use realloc to increase account space in Anchor?

Lets say that I have the following account struct for my instruction: #[derive(Accounts)] pub struct IncreaseDataSize<'info> { #[account( mut, seeds = [signer.key().as_ref()],...
Matheus Baptistella's user avatar
4 votes
1 answer
262 views

Why does `solana program show <address>` and `solana accounts <address>` return different values for the `data length` and `balance` fields

Originally asked in the SolanaU discord. Is there a reason why the Solana CLI will return different values for solana program show and solana account? solana program show ...
Jimii's user avatar
  • 7,712
4 votes
2 answers
105 views

Can I fetch data from within the program? [closed]

If I generate PDA within my program like this: let (pda,_) = Pubkey::find_program_address(&[ &(game_data.id).to_be_bytes(), game_data.key().as_ref() ], &ID); Can I fetch the field,...
CryptoSar's user avatar
  • 419
4 votes
1 answer
943 views

Access Phantom account with Solana CLI

I have created a Solana account with Phantom App. How can I access my Phantom account details and balance via through Solana CLI? Please list down all the libraries also required for it.
Rajat's user avatar
  • 147
4 votes
1 answer
359 views

Can I call 'get account info' in instruction in rust?

I'd like to get account info from pubkey of account in instruction method in rust. like this, // instructions.rs fn instruction_method() -> Instruction { let pubkey: Pubkey; let account_info =...
blockartist's user avatar
4 votes
3 answers
576 views

"Signature verification failed" error while creating an account

I am trying to create an account but I get an error while creating it. const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); const newAccountKeypair = anchor.web3.Keypair....
curiosity's user avatar
  • 509
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 ...
GoT's user avatar
  • 97
4 votes
1 answer
2k views

Calculating Solana Fees

How are fees calculated in Solana ?
vicyyn's user avatar
  • 4,295
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&...
Yilmaz's user avatar
  • 1,264
4 votes
1 answer
128 views

Transaction history is empty on NFT mint account

I have this NFT's mint address on devnet where no transaction history can be found: E4xbqXvy1tHjfBwJpR5WT4h3xMXgmb5UX7wkoChUPB4g I'm confused how this is happened, because I also have the transaction ...
Jinwoo An's user avatar
4 votes
1 answer
155 views

How does borsh serialize updated data back into account?

In the code from the project here, the processing logic is as follows: pub struct Processor {} impl Processor { pub fn process_instruction( _program_id: &Pubkey, accounts: &...
Finlay Weber's user avatar
4 votes
1 answer
152 views

How to write on-chain program leveraging the "Address Lookup Table" feature

I would like to write an on-chain program that leverages the "Address Lookup Table" feature (https://github.com/solana-labs/solana/issues/26391). I would like the on-chain program to de-...
Yifan Jiang's user avatar
3 votes
3 answers
321 views

Extending struct fields in a PDA and ensuring compatibility

I need to extend the fields I have within a PDA. Some accounts are already live, so I want those to still be compatible with the new layout. As a simple illustrative example, consider this account ...
mega_creamery's user avatar
3 votes
1 answer
2k views

How to close a PDA account?

#[account( init, seeds = [ b"config".as_ref(), mint.key().as_ref(), ], bump, payer = sender, space = 90 ...
Abhishek Faliya's user avatar
3 votes
2 answers
436 views

Anchor: does an account being initialized (not PDA) need to be a signer?

I have the following accounts in an instruction: #[derive(Accounts)] pub struct CreatePixel<'info> { #[account(init, payer=user, space=Pixel::LEN)] pub pixel: Account<'info, Pixel>,...
Callum M's user avatar
  • 3,775
3 votes
1 answer
641 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 ...
Rounak Naik's user avatar
3 votes
1 answer
112 views

Undefined owner in token balances structure even though there's an owner

When calling getParsedTransaction, in the tokenBalances here I get an undefined owner even though the token account has an owner? Here is example getting the transaction info for ...
vicyyn's user avatar
  • 4,295
3 votes
1 answer
277 views

In what context is the hash of a ed25519 public key used as an address?

According to the docs, a Solana address is one of the following: an ed25519 public key a program-derived account address (32byte value forced off the ed25519 curve) a hash of an ed25519 public key ...
McBain's user avatar
  • 5,384
3 votes
1 answer
70 views

How to allocate `Optional` accounts on heap?

I am trying to use optional accounts and since there are many accounts, i tried boxing them. But looks like the derive macro panics when i try to box the optional accounts like below. escrow_account: ...
Dhruv D Jain's user avatar
3 votes
1 answer
406 views

Why do we convert accounts to AccountInfo?

I have this rust function pub fn purchase_ticket(ctx: Context<PurchaseTicket>, lottery_id: u32) -> Result<()> { let lottery = &mut ctx.accounts.lottery; let ticket = &...
Yilmaz's user avatar
  • 1,264
3 votes
1 answer
801 views

what is anchor #[instruction()] macro?

I have this code: #[derive(Accounts)] #[instruction(campaign_id: u32)] pub struct CreateCompaign<'info> { #[account( mut, seeds = [SEED.as_bytes(), &campaign_id....
Yilmaz's user avatar
  • 1,264
3 votes
3 answers
177 views

Can't initialize PDA cause of seed constraint, even though seeds are correct

I am trying to create a PDA with variable seeds like this #[derive(Accounts)] #[instruction(i: u8)] pub struct SendRequest<'info> { #[account(mut)] pub owner: Signer<'info>, #...
Abhishek Faliya's user avatar
3 votes
1 answer
273 views

How to save an array of 10,000 public keys on an account

Is there a scalable way to save an array of public keys ? I'm building a raffle type of system using Anchor framework, where we would want to save all public keys in an array, so we can pick a winner ...
Bahdcoder's user avatar
  • 131
3 votes
1 answer
210 views

Creating a data account per user of your program?

I have the following use case. Users can enter a lottery by bidding a certain amount. The program keeps track of the users and their bid amounts in its own data account (just an array of pub keys ...
daoplays's user avatar
  • 597
3 votes
1 answer
298 views

Can you create accounts with less lamports than the rent-exempt minimum?

Accounts on Solana are considered rent-exempt if they hold at least the cost of their rent for 2 years (based on the size of the account's data). Is it possible to create an account that's not rent-...
Joe C's user avatar
  • 1,116
3 votes
1 answer
355 views

How do you repopen a closed account?

If an account has been closed with the following anchor context: #[account( mut, close = user, seeds = [ SEED_SCHEMA.as_bytes(), &user.key().as_ref()...
mega_creamery's user avatar
3 votes
2 answers
432 views

Why did I get access to the wallet?

I generated a 12-word BIP39 word sequence using a third-party library (not from the solana tools). Next, I went to the phantom mobile application and added a wallet by restoring it using a 12-word ...
Leo Loki's user avatar
  • 464
3 votes
1 answer
624 views

Getting transaction info on account changes using JS

Using JS, how would I go about getting transaction information on transactions that affect the balance of a specific account? I've been able to listen for account changes with the following code, but ...
gxc's user avatar
  • 165

1
2 3 4 5