Accounts represent the on-chain data structures stored by your Solana program. These endpoints allow you to retrieve the complete schema for all account types defined in the program’s IDL.
Anchor programs use 8-byte discriminators to identify account types. The discriminator is stored as the first 8 bytes of the account data and is derived from a hash of the account type name.
Once you’ve identified an account type using its discriminator, you can deserialize the remaining data according to the field schema.
import { Program } from '@project-serum/anchor';import { Connection, PublicKey } from '@solana/web3.js';// Fetch and deserialize a Pool accountconst connection = new Connection('https://api.mainnet-beta.solana.com');const poolAddress = new PublicKey('...');const poolAccount = await program.account.pool.fetch(poolAddress);console.log('Reserve A:', poolAccount.reserveA.toString());console.log('Reserve B:', poolAccount.reserveB.toString());
No authentication required - This endpoint is public for all public projects.
Use the discriminator values to filter and identify account types when fetching accounts using getProgramAccounts.
Field types are resolved recursively. Complex types like vec<CustomStruct> will show the full type representation including nested structures.
Account data size is determined by the sum of all field sizes plus the 8-byte discriminator. Ensure your rent calculations account for the full data size.