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 answers only not deleted user 153
2 votes

How to define constant Pubkeys while developing with Anchor?

Edit: Per @trent.sol comment, there is an even more natural macro that can be used: use solana_program::{pubkey, pubkey::Pubkey}; static ID: Pubkey = pubkey!("My11111111111111111111111111111111111111 …
sohrab's user avatar
  • 1,851
4 votes
Accepted

What's the difference between Anchor Accounts and account attributes?

Accounts is just a trait, while #[account] is a macro that generates code. Accounts trait is literally just the below. There is no "functionality". pub trait Accounts<'info>: ToAccountMetas + ToAccoun …
sohrab's user avatar
  • 1,851
1 vote

Why is this function failing to fetch my program account's public key?

I feel you are running out of space on base_account. You have allocated 10000 bytes. Let's look at how much space it will take to store this: 8 [discriminator] + 8 [total_posts] + 4 [vector prefix] + …
sohrab's user avatar
  • 1,851
2 votes
Accepted

Can I read information stored by a PDA without having to deserialize its byte array?

You should be able to get any account and deserialise it using the client: let program = client.program(*Program Address*); let my_data: MyData = program.account(*PDA ADDRESS*)?; You can see similar …
sohrab's user avatar
  • 1,851
6 votes
Accepted

How can I create a PDA account dynamically or conditionally

The best way to see what Anchor is currently doing is to use anchor expand to see the expanded macros. Then you can pull that logic inside your own function. How can we check if a PDA account alread …
sohrab's user avatar
  • 1,851
3 votes
Accepted

Intitalize Solana Program through IDL

Unfortunately, anchor_client is not IDL-aware. It is intended for scenarios where you have access to the source code (or crate) of the program you are calling. You can see an example of this the Ancho …
sohrab's user avatar
  • 1,851
1 vote

How to store signatures in a Solana account

Signatures can be stored as 64 bytes. Simply decode it back, say using bs58: pub struct MyAccount { signature: [u8; 64], } let my_account = MyAccount { signature: bs58::decode("<your signature b5 …
sohrab's user avatar
  • 1,851
7 votes
Accepted

Do I have to use Borsh for serialization?

Do you perchance mean Borsh? Solana is not opinionated about which serialisation/deserialisation library you use in your program. The protocol just expects a byte array for account and instruction dat …
sohrab's user avatar
  • 1,851