Read data from the Solana network by fetching different accounts. This guide explains the structure of Solana accounts. Each Solana account has a unique address that is used to locate the account's onchain data. Solana accounts contain either state data or an executable program.
Fetch a wallet account
A wallet account is an account owned by the System Program. Wallet accounts are primarily used to hold SOL and sign transactions. When SOL is sent to a new address for the first time, a system account is automatically created.
The example below creates a Kit client, generates a new signer, requests SOL to fund the new address, and retrieves the account data from the client's RPC API.
import { createClient, generateKeyPairSigner, lamports } from "@solana/kit";import { solanaRpc, rpcAirdrop } from "@solana/kit-plugin-rpc";import { generatedPayer } from "@solana/kit-plugin-signer";const client = await createClient().use(generatedPayer()).use(solanaRpc({rpcUrl: "http://localhost:8899",rpcSubscriptionsUrl: "ws://localhost:8900"})).use(rpcAirdrop());const signer = await generateKeyPairSigner();console.log(`Address: ${signer.address}`);// Funding an address with SOL automatically creates an accountawait client.airdrop(signer.address, lamports(1_000_000_000n));const accountInfo = await client.rpc.getAccountInfo(signer.address).send();console.log(accountInfo);
When you fetch a wallet account with getAccountInfo(), Kit returns the RPC
response shown in the example output on the right.
The response has two top-level fields: context describes when the read
happened, and value contains the account fields returned by the RPC method.
{context: {slot: 420602714n,apiVersion: "3.1.6"},value: {lamports: 1000000000n,data: ["", "base64"],owner: "11111111111111111111111111111111",executable: false,rentEpoch: 0n,space: 0n}}
The context field shows the slot used to read the account and the RPC API
version that served the response. A later read can return a different slot or
API version.
{context: {slot: 420602714n,apiVersion: "3.1.6"},value: {lamports: 1000000000n,data: ["", "base64"],owner: "11111111111111111111111111111111",executable: false,rentEpoch: 0n,space: 0n}}
The value field contains the account state returned by the RPC method. The
following steps walk through the fields inside value in the order the fields
appear.
{context: {slot: 420602714n,apiVersion: "3.1.6"},value: {lamports: 1000000000n,data: ["", "base64"],owner: "11111111111111111111111111111111",executable: false,rentEpoch: 0n,space: 0n}}
The lamports field contains the account's SOL balance, measured in
lamports, the smallest unit of SOL.
{context: {slot: 420602714n,apiVersion: "3.1.6"},value: {lamports: 1000000000n,data: ["", "base64"],owner: "11111111111111111111111111111111",executable: false,rentEpoch: 0n,space: 0n}}
The data field contains the account's data stored as bytes. RPC returns
account data as a tuple: the encoded data string, followed by the encoding. For
wallet accounts, the encoded data string is empty because the account stores 0
bytes of data.
{context: {slot: 420602714n,apiVersion: "3.1.6"},value: {lamports: 1000000000n,data: ["", "base64"],owner: "11111111111111111111111111111111",executable: false,rentEpoch: 0n,space: 0n}}
The owner field shows the program that owns the account. For wallets, the
owner is always the System Program, with the address
11111111111111111111111111111111.
{context: {slot: 420602714n,apiVersion: "3.1.6"},value: {lamports: 1000000000n,data: ["", "base64"],owner: "11111111111111111111111111111111",executable: false,rentEpoch: 0n,space: 0n}}
The executable field tells you whether the account's address is callable.
true means the address represents a program that can process instructions.
false means the account stores state, such as a wallet balance or account
data, and is not called as a program. Wallet accounts use false.
{context: {slot: 420602714n,apiVersion: "3.1.6"},value: {lamports: 1000000000n,data: ["", "base64"],owner: "11111111111111111111111111111111",executable: false,rentEpoch: 0n,space: 0n}}
The rentEpoch field is a legacy field from a deprecated rent mechanism. The
field is still returned for backward compatibility.
{context: {slot: 420602714n,apiVersion: "3.1.6"},value: {lamports: 1000000000n,data: ["", "base64"],owner: "11111111111111111111111111111111",executable: false,rentEpoch: 0n,space: 0n}}
The space field shows the number of bytes contained in the data field. The
space field is returned with the account-fetching response, but it is not part
of the account's data type.
For the wallet account example, the space field is 0 because the data field
contains 0 bytes of data.
{context: {slot: 420602714n,apiVersion: "3.1.6"},value: {lamports: 1000000000n,data: ["", "base64"],owner: "11111111111111111111111111111111",executable: false,rentEpoch: 0n,space: 0n}}
Fetch the Token Program
The example below fetches the Token Program to demonstrate the difference between wallet and program accounts. The Token Program defines instructions for working with tokens, such as creating and transferring tokens. Programs are invoked to process instructions. Program state, such as token data and balances, are stored in separate accounts owned by the program.
The Token Program's address is the onchain Program account. For simplicity, you can think of the program address as the program, because that is the address used to invoke it. For upgradeable programs, the Program account stores metadata and points to a separate ProgramData account that stores the deployed executable code. You can view the Token Program source code and the Program account on the Solana Explorer.
import { address, createClient, fetchJsonParsedAccount } from "@solana/kit";import { solanaRpc } from "@solana/kit-plugin-rpc";import { generatedPayer } from "@solana/kit-plugin-signer";const client = await createClient().use(generatedPayer()).use(solanaRpc({rpcUrl: "https://api.mainnet.solana.com"}));const tokenProgramAddress = address("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");const accountInfo = await client.rpc.getAccountInfo(tokenProgramAddress, {encoding: "base64"}).send();console.log(accountInfo);const parsedAccount = await fetchJsonParsedAccount(client.rpc,tokenProgramAddress);console.log(parsedAccount);
The Token Program is an executable program account. Programs have the same underlying fields as all accounts, but with key differences.
The Token Program example uses base64 encoding to return the Program account's
raw data.
The following steps walk through the fields inside value in the order the
fields appear.
{context: {apiVersion: "3.1.14",slot: 420601581n},value: {data: ["AgAAACfxkLHTr5i4znFMROjK3/n4/EXLjl+sQgLv+BENl903", "base64"],executable: true,lamports: 2191440n,owner: "BPFLoaderUpgradeab1e11111111111111111111111",rentEpoch: 18446744073709551615n,space: 36n}}
The data field stores the BPF Upgradeable Loader's Program account state. The
first tuple item contains the full account data encoded as base64. The second
tuple item identifies the encoding. Here, the 36 bytes include metadata and the
ProgramData account address.
For upgradeable programs, the Program account state points to the separate ProgramData account that stores the program's executable code.
{context: {apiVersion: "3.1.14",slot: 420601581n},value: {data: ["AgAAACfxkLHTr5i4znFMROjK3/n4/EXLjl+sQgLv+BENl903", "base64"],executable: true,lamports: 2191440n,owner: "BPFLoaderUpgradeab1e11111111111111111111111",rentEpoch: 18446744073709551615n,space: 36n}}
The executable field is set to true, which indicates that the account's
address can be invoked as a program.
{context: {apiVersion: "3.1.14",slot: 420601581n},value: {data: ["AgAAACfxkLHTr5i4znFMROjK3/n4/EXLjl+sQgLv+BENl903", "base64"],executable: true,lamports: 2191440n,owner: "BPFLoaderUpgradeab1e11111111111111111111111",rentEpoch: 18446744073709551615n,space: 36n}}
The lamports field contains the SOL balance held by the Program account.
Program accounts need enough lamports to remain rent-exempt.
{context: {apiVersion: "3.1.14",slot: 420601581n},value: {data: ["AgAAACfxkLHTr5i4znFMROjK3/n4/EXLjl+sQgLv+BENl903", "base64"],executable: true,lamports: 2191440n,owner: "BPFLoaderUpgradeab1e11111111111111111111111",rentEpoch: 18446744073709551615n,space: 36n}}
Every program account is owned by a
loader program. For
the Token Program account, the owner is the BPF Upgradeable Loader.
{context: {apiVersion: "3.1.14",slot: 420601581n},value: {data: ["AgAAACfxkLHTr5i4znFMROjK3/n4/EXLjl+sQgLv+BENl903", "base64"],executable: true,lamports: 2191440n,owner: "BPFLoaderUpgradeab1e11111111111111111111111",rentEpoch: 18446744073709551615n,space: 36n}}
The rentEpoch field is a legacy field from a deprecated rent mechanism. The
field is still returned for backward compatibility.
{context: {apiVersion: "3.1.14",slot: 420601581n},value: {data: ["AgAAACfxkLHTr5i4znFMROjK3/n4/EXLjl+sQgLv+BENl903", "base64"],executable: true,lamports: 2191440n,owner: "BPFLoaderUpgradeab1e11111111111111111111111",rentEpoch: 18446744073709551615n,space: 36n}}
The space field shows the full size of the Program account's data in bytes.
The space value is only 36 bytes because the Program account stores loader
metadata and the address of the ProgramData account, not the full compiled
program.
{context: {apiVersion: "3.1.14",slot: 420601581n},value: {data: ["AgAAACfxkLHTr5i4znFMROjK3/n4/EXLjl+sQgLv+BENl903", "base64"],executable: true,lamports: 2191440n,owner: "BPFLoaderUpgradeab1e11111111111111111111111",rentEpoch: 18446744073709551615n,space: 36n}}
The previous response returned the Program account's data field as a base64
tuple. The parsed response deserializes those bytes into named fields on the
data object. The programData field contains the address of the ProgramData
account that stores the executable program code.
{executable: true,lamports: 43712780n,programAddress: "BPFLoaderUpgradeab1e11111111111111111111111",space: 36n,address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",data: {programData: "3gvYRKWyXRR9xKWe1ZjPhLY5ZJRN7KDB4rFZFGoJfFk2",parsedAccountMeta: { program: "bpf-upgradeable-loader", type: "program" }},exists: true}
Fetch a mint account
A mint account is an account owned by the Token Program that stores global metadata for a specific token. The mint account stores the token's total supply, number of decimals, mint authority, and freeze authority. The mint account's address uniquely identifies a token on the Solana network.
The example below fetches the USD Coin Mint account to demonstrate how a program's state is stored in a separate account. Exact balances and supply values may differ depending on the slot your RPC node reads from.
import { address, createClient } from "@solana/kit";import { solanaRpc } from "@solana/kit-plugin-rpc";import { generatedPayer } from "@solana/kit-plugin-signer";const client = await createClient().use(generatedPayer()).use(solanaRpc({rpcUrl: "https://api.mainnet.solana.com"}));const mintAddress = address("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");const accountInfo = await client.rpc.getAccountInfo(mintAddress, {encoding: "base64"}).send();console.log(accountInfo);
Mint accounts store state, not executable code. Mint accounts are owned by the Token Program, which includes instructions defining how to create and update mint accounts.
The following steps walk through the fields inside value in the order the
fields appear.
{context: {slot: 325000000n,apiVersion: "3.1.14"},value: {data: ["AQAAAJj+huiNm+Lqi8HMpIeLKYjCQPUrhCS/tA7Rot3LXhmbbq9O2SvsHwAGAQEAAABicKqKWcWUBbRShshncubNEm6bil06OFNtN/e0FOi2Zw==","base64"],executable: false,lamports: 407438077149n,owner: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",rentEpoch: 18446744073709551615n,space: 82n}}
The data field contains the serialized Mint account state. The first tuple
item contains the full 82-byte account data encoded as base64. The second tuple
item identifies the encoding.
To read from a Mint account, you must deserialize the data field into the
Mint data type, which is shown in the
next example.
{context: {slot: 325000000n,apiVersion: "3.1.14"},value: {data: ["AQAAAJj+huiNm+Lqi8HMpIeLKYjCQPUrhCS/tA7Rot3LXhmbbq9O2SvsHwAGAQEAAABicKqKWcWUBbRShshncubNEm6bil06OFNtN/e0FOi2Zw==","base64"],executable: false,lamports: 407438077149n,owner: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",rentEpoch: 18446744073709551615n,space: 82n}}
The executable field indicates whether the account can be invoked as a
program. Mint accounts store state, so the executable field is false.
{context: {slot: 325000000n,apiVersion: "3.1.14"},value: {data: ["AQAAAJj+huiNm+Lqi8HMpIeLKYjCQPUrhCS/tA7Rot3LXhmbbq9O2SvsHwAGAQEAAABicKqKWcWUBbRShshncubNEm6bil06OFNtN/e0FOi2Zw==","base64"],executable: false,lamports: 407438077149n,owner: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",rentEpoch: 18446744073709551615n,space: 82n}}
The lamports field contains the SOL balance held by the mint account. The
lamports value is the mint account's rent-exempt balance, not the token supply.
{context: {slot: 325000000n,apiVersion: "3.1.14"},value: {data: ["AQAAAJj+huiNm+Lqi8HMpIeLKYjCQPUrhCS/tA7Rot3LXhmbbq9O2SvsHwAGAQEAAABicKqKWcWUBbRShshncubNEm6bil06OFNtN/e0FOi2Zw==","base64"],executable: false,lamports: 407438077149n,owner: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",rentEpoch: 18446744073709551615n,space: 82n}}
The mint account is owned by the
Token Program. The mint account's
data field can only be modified by the Token Program's instructions.
{context: {slot: 325000000n,apiVersion: "3.1.14"},value: {data: ["AQAAAJj+huiNm+Lqi8HMpIeLKYjCQPUrhCS/tA7Rot3LXhmbbq9O2SvsHwAGAQEAAABicKqKWcWUBbRShshncubNEm6bil06OFNtN/e0FOi2Zw==","base64"],executable: false,lamports: 407438077149n,owner: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",rentEpoch: 18446744073709551615n,space: 82n}}
The rentEpoch field is a legacy field from a deprecated rent mechanism. The
field is still returned for backward compatibility.
{context: {slot: 325000000n,apiVersion: "3.1.14"},value: {data: ["AQAAAJj+huiNm+Lqi8HMpIeLKYjCQPUrhCS/tA7Rot3LXhmbbq9O2SvsHwAGAQEAAABicKqKWcWUBbRShshncubNEm6bil06OFNtN/e0FOi2Zw==","base64"],executable: false,lamports: 407438077149n,owner: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",rentEpoch: 18446744073709551615n,space: 82n}}
The space field shows that the mint account contains 82 bytes of data.
{context: {slot: 325000000n,apiVersion: "3.1.14"},value: {data: ["AQAAAJj+huiNm+Lqi8HMpIeLKYjCQPUrhCS/tA7Rot3LXhmbbq9O2SvsHwAGAQEAAABicKqKWcWUBbRShshncubNEm6bil06OFNtN/e0FOi2Zw==","base64"],executable: false,lamports: 407438077149n,owner: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",rentEpoch: 18446744073709551615n,space: 82n}}
Deserialize mint account
Account data is stored in the data field in a serialized format. To read that
data as fields like supply or decimals, deserialize the data field into
the account type defined by the owning program. Most Solana programs provide
client libraries with helper functions for this step. These helpers return
structured account data, making the result easier to work with.
For example, the @solana-program/token library includes the
fetchMint() function to fetch a mint account and
deserialize the mint account's data field into the
Mint
data type defined by the Token Program.
import { address, createClient } from "@solana/kit";import { solanaRpc } from "@solana/kit-plugin-rpc";import { generatedPayer } from "@solana/kit-plugin-signer";import { fetchMint } from "@solana-program/token";const client = await createClient().use(generatedPayer()).use(solanaRpc({rpcUrl: "https://api.mainnet.solana.com"}));const mintAddress = address("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");const mint = await fetchMint(client.rpc, mintAddress);console.log(mint);
pub struct Mint {/// Optional authority used to mint new tokens. The mint authority may only/// be provided during mint creation. If no mint authority is present/// then the mint has a fixed supply and no further tokens may be/// minted.pub mint_authority: COption<Pubkey>,/// Total supply of tokens.pub supply: u64,/// Number of base 10 digits to the right of the decimal place.pub decimals: u8,/// Is `true` if this structure has been initializedpub is_initialized: bool,/// Optional authority to freeze token accounts.pub freeze_authority: COption<Pubkey>,}
The fetchMint() function fetches a mint account and deserializes the mint
account's data field into the Mint account type.
{context: {slot: 325000000n,apiVersion: "3.1.14"},value: {data: ["AQAAAJj+huiNm+Lqi8HMpIeLKYjCQPUrhCS/tA7Rot3LXhmbbq9O2SvsHwAGAQEAAABicKqKWcWUBbRShshncubNEm6bil06OFNtN/e0FOi2Zw==","base64"],executable: false,lamports: 407438077149n,owner: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",rentEpoch: 18446744073709551615n,space: 82n}}
You can view the fully deserialized mint account data on the Solana Explorer.
{address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",data: {mintAuthority: {__option: "Some",value: "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG"},supply: 8985397351591790n,decimals: 6,isInitialized: true,freezeAuthority: {__option: "Some",value: "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar"}},executable: false,lamports: 407438077149n,programAddress: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",space: 82n}
The address field contains the mint account's address.
{address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",data: {mintAuthority: {__option: "Some",value: "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG"},supply: 8985397351591790n,decimals: 6,isInitialized: true,freezeAuthority: {__option: "Some",value: "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar"}},executable: false,lamports: 407438077149n,programAddress: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",space: 82n}
The data field contains the deserialized Mint account state. The nested
fields in data come from the Token Program's Mint account type.
{address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",data: {mintAuthority: {__option: "Some",value: "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG"},supply: 8985397351591790n,decimals: 6,isInitialized: true,freezeAuthority: {__option: "Some",value: "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar"}},executable: false,lamports: 407438077149n,programAddress: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",space: 82n}
The data.mintAuthority field shows the only account that can create new units
of the token.
{address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",data: {mintAuthority: {__option: "Some",value: "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG"},supply: 8985397351591790n,decimals: 6,isInitialized: true,freezeAuthority: {__option: "Some",value: "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar"}},executable: false,lamports: 407438077149n,programAddress: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",space: 82n}
The supply field shows the total number of tokens that have been minted. The
supply value is measured in the smallest unit of the token. To get the total
supply in standard units, adjust the value of the supply field by the
decimals.
{address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",data: {mintAuthority: {__option: "Some",value: "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG"},supply: 8985397351591790n,decimals: 6,isInitialized: true,freezeAuthority: {__option: "Some",value: "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar"}},executable: false,lamports: 407438077149n,programAddress: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",space: 82n}
The decimals field shows the number of decimal places for the token.
{address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",data: {mintAuthority: {__option: "Some",value: "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG"},supply: 8985397351591790n,decimals: 6,isInitialized: true,freezeAuthority: {__option: "Some",value: "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar"}},executable: false,lamports: 407438077149n,programAddress: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",space: 82n}
The isInitialized field indicates whether the mint account has been
initialized. The isInitialized field is a security check used in the Token
Program.
{address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",data: {mintAuthority: {__option: "Some",value: "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG"},supply: 8985397351591790n,decimals: 6,isInitialized: true,freezeAuthority: {__option: "Some",value: "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar"}},executable: false,lamports: 407438077149n,programAddress: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",space: 82n}
The data.freezeAuthority field shows the account with authority to freeze
token accounts. A token account is a
separate account that stores units of a token for an owner. When frozen, a token
account cannot transfer or burn its token balance.
{address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",data: {mintAuthority: {__option: "Some",value: "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG"},supply: 8985397351591790n,decimals: 6,isInitialized: true,freezeAuthority: {__option: "Some",value: "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar"}},executable: false,lamports: 407438077149n,programAddress: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",space: 82n}
The executable field is false. The USDC mint account stores token state, so
the USDC mint account cannot be invoked as a program.
{address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",data: {mintAuthority: {__option: "Some",value: "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG"},supply: 8985397351591790n,decimals: 6,isInitialized: true,freezeAuthority: {__option: "Some",value: "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar"}},executable: false,lamports: 407438077149n,programAddress: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",space: 82n}
The lamports field contains the SOL balance held by the mint account. The
lamports value is the mint account's rent-exempt balance, not the token supply.
{address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",data: {mintAuthority: {__option: "Some",value: "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG"},supply: 8985397351591790n,decimals: 6,isInitialized: true,freezeAuthority: {__option: "Some",value: "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar"}},executable: false,lamports: 407438077149n,programAddress: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",space: 82n}
The programAddress field shows the program that owns the mint account. For
USDC, the owning program is the Token Program. Only the program that owns an
account can modify its data field through the program's deployed instructions.
{address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",data: {mintAuthority: {__option: "Some",value: "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG"},supply: 8985397351591790n,decimals: 6,isInitialized: true,freezeAuthority: {__option: "Some",value: "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar"}},executable: false,lamports: 407438077149n,programAddress: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",space: 82n}
The space field shows the size of the original mint account data in bytes. The
Token Program's base Mint account is 82 bytes.
{address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",data: {mintAuthority: {__option: "Some",value: "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG"},supply: 8985397351591790n,decimals: 6,isInitialized: true,freezeAuthority: {__option: "Some",value: "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar"}},executable: false,lamports: 407438077149n,programAddress: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",space: 82n}
Serialized vs deserialized output
Both examples read the same USDC mint account. The first response leaves the
data field serialized. To read the mint account's contents, decode that data
as the account type defined by the owning program. For a mint account, the Token
Program defines the Mint type shown on the right.
Before decoding, the data field contains serialized
account data.
{context: {slot: 325000000n,apiVersion: "3.1.14"},value: {data: ["AQAAAJj+huiNm+Lqi8HMpIeLKYjCQPUrhCS/tA7Rot3LXhmbbq9O2SvsHwAGAQEAAABicKqKWcWUBbRShshncubNEm6bil06OFNtN/e0FOi2Zw==","base64"],executable: false,lamports: 407438077149n,owner: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",rentEpoch: 18446744073709551615n,space: 82n}}
After decoding the data as a Mint, the data field
contains named account fields.
{address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",data: {mintAuthority: {__option: "Some",value: "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG"},supply: 8985397351591790n,decimals: 6,isInitialized: true,freezeAuthority: {__option: "Some",value: "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar"}},executable: false,lamports: 407438077149n,programAddress: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",space: 82n}
Is this page helpful?