Skip to main content

Questions tagged [account]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
602 views

what's the correct way to declare an account for program to receive and store SOL?

Demo bellowed is what I figure out to make program receive SOL. But it seem have room to improve, especially 'NewAccount', which look ugly, but I can't found property Account type to replace it. I ...
breeze wang's user avatar
1 vote
2 answers
516 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 ...
Burger Bob's user avatar
  • 1,506
1 vote
1 answer
570 views

what does #[account(mut)] do in solana?

I know what procedural macros are. They are like decorators, they add new functionality or properties into the decorated code. #[account(init,payer=user,space=9000)] pub base_account:Account<'info,...
Yilmaz's user avatar
  • 1,264
1 vote
3 answers
73 views

How to bulk update accounts?

Is there a way to update a field on all the accounts owned by a program at once? Say I have a bunch of PDAs Stake { amount: usize }. Is it possible to do amount = amount * 1.1 for multiple accounts in ...
itsfarseen's user avatar
1 vote
1 answer
55 views

Account creation on Solana

Suppose I have a PDA address that hasn't been initialized yet and I send SOL to it, Am I correct in assuming that this account will exist? Who will have control over this account? Will it still be by ...
Jimii's user avatar
  • 7,712
1 vote
2 answers
220 views

Are enums with associated values permitted?

Not sure if this is really an anchor or solana related question, since I am able to compile, just not to run tests. I can run code and test against code that has an account that has following enum: #[...
mega_creamery's user avatar
1 vote
2 answers
531 views

Is it possible to create an account (new keypair) using PHP?

I don't have experience with solana yet and I have question in my work. I see that it is possible to generate a key pair with web3.js But is it possible to generate a new pshair with php ?
Leo Loki's user avatar
  • 464
1 vote
3 answers
3k views

How to recover SOL from a address after mistakenly transfer [closed]

I have transfer some SOL to a address by mistake. I still see the balance in solana explorer mainnet. Is there any way I can recover my SOL? Is there a way Solana company can help on this?
Souvagya's user avatar
  • 131
1 vote
1 answer
89 views

most efficient way computationally to check accounts on chain?

I am just trying to understand the best way to check that accounts match expected values on chain. Currently what I am doing costs 65k compute units out of a total of 200k which seems a bit extreme! ...
daoplays's user avatar
  • 597
1 vote
1 answer
418 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 ...
kyle's user avatar
  • 261
1 vote
1 answer
304 views

"error: ... An account required by the instruction is missing" when creating metaplex metadata account

I've successfully implemented the minting function. After it, I added the method to create a metadata account. However, after I call the function, I get an error: Error: failed to send transaction: ...
Kiwi's user avatar
  • 45
1 vote
2 answers
324 views

How to pay/sign an ATA with a different owner?

I'm trying to learn solana and currently doing NFTs. I'm wondering if it's possible to create an Associated Token Account with an owner that differs from the signer and then mint an NFT to that ATA? ...
Kiwi's user avatar
  • 45
1 vote
1 answer
65 views

Reducing calls to .load() in constraints

When using constraints with a zero-copy account that uses AccountLoader, you can reduce acc.load() calls like: #[account( mut, constraint = { let acc = some_acc.load()?;...
Whiteseal's user avatar
  • 3,607
1 vote
1 answer
47 views

should I split a large data account into smaller ones

I have an account that contains a lot of fields, 30+. Besides composability, is there any benefit to splitting this account into different accounts? Will it improve performance/transaction costs?
Jimii's user avatar
  • 7,712
1 vote
1 answer
489 views

"Access violation in stack frame 3 at address 0x200003ff0 of size 8 by instruction #35516" , even though I use zero copy on my account struct

This is my account struct pub struct ClaimRewards<'info> { #[account(init_if_needed, payer = payer, seeds = [OKUSEED.as_ref()], bump, mint::decimals = 6, mint::authority = mint)] pub ...
Abhishek Faliya's user avatar
1 vote
1 answer
371 views

Can a closed account in anchor be initialised again?

I am following the soldev tutorials. At the Crossing Account and Revival attacks.The program has two methods a lottery initialisation account and a redeem tokens based on the time of entering. After ...
Mr.H's user avatar
  • 117
1 vote
1 answer
1k 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?
Rounak Naik's user avatar
1 vote
1 answer
230 views

Is there way to differentiate accounts from pdas?

Out of curiosity, I was wondering if there was a way to tell just by looking at the address, if one can tell if the address is a data account or a pda instead. I'm personally having a hard time ...
alan's user avatar
  • 13
1 vote
1 answer
344 views

Is it common to have close account instruction inside my solana program

In my Solana program, users can create program-owned accounts. Although maybe they want to close it because it is no longer necessary and want to recoup the account rent/fees. I assume that closing ...
Burger Bob's user avatar
  • 1,506
1 vote
3 answers
146 views

How much of a PDA can a program control

How much of a PDA is under the control of its owner program? For example, could the program block the account from signing certain instructions on transactions? Or could the program add a fee to every ...
Pixeled's user avatar
  • 486
1 vote
2 answers
204 views

checking if a program is upgradeable

I am trying to work out how to get some meta data for Solana programs. I can see on sol explorer etc that it knows whether a program is upgradeable, and if it is, who the upgrade authority is, but I ...
daoplays's user avatar
  • 597
1 vote
1 answer
728 views

Why does "solana account" fail until after airdrop

I generate a new key pair by running: solana-keygen new --force I print out the address: solana address 2EHCPkQHcjiBUgWT6zpcHmLPbW2r6wKtb9RjYnoBwFb7 Now I tried to get the account details associated ...
dade's user avatar
  • 292
1 vote
2 answers
1k views

Account size calculation when using vectors

I just measured account size with std::mem::size_of because I was curious how space is calculated for vectors. Following the docs, I would have assumed that size_of would add 4 bytes for each vector, ...
Sebastian Dine's user avatar
1 vote
1 answer
326 views

How do I make a PDA own a system account

So im making a program that CPIs into marinade. In one of the instructions, they have a "transfer_sol_to" account requirement. I want the sol from that instruction to be transferred to a ...
SwayStar123's user avatar
1 vote
1 answer
117 views

How can I preserve the original data and add the new data to my account when using the realloc method?

So when increasing the data size of my account I of course would add some additional fields in my Struct. So on the basis of new Struct I won't be able to deserialize the previous data. Do i need to ...
Muhammad Ali's user avatar
1 vote
2 answers
108 views

how can anchor program A read account data from anchor program B with #account macro way?

My anchor program "A", expect to use data from a anchor program name "B". Let's say program_b (which I don't have code, just know it's address) has declare PDA account data struct: ...
breeze wang's user avatar
1 vote
2 answers
246 views

My account has become a Token Account, how can I solve it?

My account that I used commonly had some solanas which I left untouched for a while, now I tried to move my solanas again and it gives me an error and it doesn't allow me to make any transaction or ...
jeo's user avatar
  • 11
1 vote
1 answer
75 views

Who owns the private key of delegated Staked Accounts?

I see on solscan.io account pages that most of them have isOnCurve false, but my delegated staked account has isOnCurve true. Does this mean someone has the private key of this account? Who? Usual ...
Unicornist's user avatar
1 vote
1 answer
597 views

obtain the contract of a token through the address of a holder

I am currently learning the basics of programming in solana using the different json functions and I have a question Is there a function that gives you the contract of a token having only the address ...
lea's user avatar
  • 11
1 vote
1 answer
379 views

Issues with Using AnchorSerialize and AnchorDeserialize Traits

so I'm looking to create an instruction that creates an account called GamePot that contains a field called TokenInfo that holds the data for what is meant to be any particular SPL token with a mint ...
Brian M.'s user avatar
  • 141
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/...
Abhishek Faliya's user avatar
1 vote
1 answer
1k views

Error: AnchorError: AnchorError caused by account: base_account. Error Code: AccountNotInitialized

I wrote a Solana Program with two functions, one for the initialization of an account and a second to upload data to the account. While testing on localhost it was working fine, but when I uploaded it ...
Rounak Naik's user avatar
1 vote
1 answer
229 views

How to handle multiple tokens + SOL in a payments program?

Context Depending on the item price in USD, users should be able to pay for items with different tokens/currencies (this is made possible with Switchboard Oracles). The payments then go towards a ...
Burger Bob's user avatar
  • 1,506
1 vote
2 answers
187 views

What happens to old program-owned-accounts when adding a new field to the account structure?

Let us suppose users are able to create a program-owned-account: PurchaseItemAccount, which is deployed as: { id: u64 price: u64 } After some time, I then decide to add a field, ...
Burger Bob's user avatar
  • 1,506
1 vote
1 answer
91 views

What does range full operator do in borsh serialize?

I follow hackernoon-solana to see the syntax in non anchor project. this is the function signature pub fn process_instruction(program_id:&Pubkey,accounts:&[AccountInfo],input:&[u8])->...
Yilmaz's user avatar
  • 1,264
1 vote
1 answer
60 views

Programs deployed to Solana do not last forever right?

I am learning about the account model in solana and got to the part about Rent. From what I understand if the lamport falls below a particular level, the accounts get purged. This means programs ...
Finlay Weber's user avatar
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)] ...
coco's user avatar
  • 83
1 vote
1 answer
34 views

run across an verify interesting account on browser, how to the holder spend it?

I run into a account on the browser. https://solscan.io/account/41BJ8cmr4vaebFbHzxerb8YG6MmTFWLj15M6h65mUyiF https://explorer.solana.com/address/41BJ8cmr4vaebFbHzxerb8YG6MmTFWLj15M6h65mUyiF From ...
breeze wang's user avatar
1 vote
2 answers
25 views

Error creating new account using mint

While trying to create new accounts I am having issues. Could be accounts cannot be created after disabling mint. spl-token create-account mntZFtv8SvH6trqeSwvTGPVSXXXXXXXXX --owner reserve.json Error:...
Dom's user avatar
  • 21
1 vote
1 answer
13 views

Must the nested-instructions's accounts be passed in, as well?

Does the accounts field of a program's Instruction include just the accounts the instruction needs/touches directly - or those that are required by the nested instructions called by it, as well? It ...
Iaroslav's user avatar
  • 199
1 vote
2 answers
420 views

Why can't I send out my solana from phantom

When I attempt to do so it says something along the lines of unable to send or failed also transaction failed during simulation My wallet is EYsJVQU5igQNaNMptsyL2A6h6QWso34MYxTriAkdQqWj I am not sure ...
asset's user avatar
  • 11
1 vote
1 answer
59 views

Avoid unnecessary account generation

For context, I am trying to implement a contract I have on solidity to solana. On solidity, I have a function like this, which writes data to state based on a condition. function handleMessage(bytes ...
woodland's user avatar
1 vote
1 answer
295 views

MODULE NOT FOUND

import * as dotenv from 'dotenv'; dotenv.config(); import { getKeypairFromEnvironment } from '@solana-developers/helpers'; const keypair = getKeypairFromEnvironment("SECRET_KEY"); console....
Kabin Giri's user avatar
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 { ...
S.R's user avatar
  • 141
1 vote
1 answer
298 views

What determines the size of a program

How is the size of a program calculated? If all accounts have a limit of 10 kibibytes, I assume that also applies to programs as well? How will the extend program size affect this? does it allow me to ...
Jimii's user avatar
  • 7,712
1 vote
4 answers
360 views

Failed Token Develop and Lose Money :) [closed]

Before I start, I would like to apologize for writing a long message. I am a novice software developer who is just starting to learn Solana. Therefore, I wrote the whole story from start to finish ...
TryingToBeSolDev's user avatar
1 vote
1 answer
59 views

Is there a throttle in place for account creations or can I create accounts at 50k tps?

Other networks have throttles, I noticed there is a minimum balance on Solana, so does that mean as long as I have enough SOL I can create accounts at a rate of 50k tps? @ripatel
Michael's user avatar
  • 13
1 vote
1 answer
146 views

Get all accounts from ledger

To obtain all account information from the ledger, I used the following command: solana-ledger-tool --ledger /mnt/ledger/ accounts However, only the following information is printed, and the account ...
Solextra's user avatar
1 vote
1 answer
142 views

How to calculate space for an account dynamically using remaining_accounts

Is it possible to allocate space to an account based on account provided in remaining_accounts? I want to allocate enough space to store public key of the accounts provided in remaining_accounts in a ...
onurhb's user avatar
  • 113
1 vote
1 answer
54 views

derive correct account inside a different anchor context

Let's say I have this CampaignCount account: #[account] pub struct CampaignCount { // I keep track of how many campaigns I have so far pub id: u32, } Imagine I need to refer to this in the ...
Yilmaz's user avatar
  • 1,264