Home  >  Article  >  How to find sub-account balance in solana

How to find sub-account balance in solana

DDD
DDDOriginal
2024-04-30 14:56:06663browse

To find the balance of a Solana subaccount: obtain its public key; use SolanaExplorer, SolanaCLI, or development tools to query the balance.

How to find sub-account balance in solana

How to find the Solana sub-account balance

Step 1: Obtain the sub-account public key

To find the balance of a subaccount, you need to know its public key. You can obtain the sub-account public key through the following methods:

  • Request directly from the sub-account owner
  • Generate using a wallet that supports derived accounts (such as Phantom or Slope wallet)
  • Usingspl-token The library is derived from the parent account address

Step 2: Query the account balance

Using the child Account public key, you can check its balance through the following method:

  • Use Solana Explorer:

    • Go to Solana Explorer (https: //explorer.solana.com/)
    • Enter the subaccount public key in the search bar
    • View the "Tokens" tab to find the token balance
  • Using Solana CLI:

    • Open a terminal or command prompt
    • Enter the following command:
    solana --url https://api.devnet.solana.com/ get-token-accounts publicKeyOfSubaccount

    Where"publicKeyOfSubaccount" is the public key of the sub-account.

  • Use development tools:

    • Use tools such as web3.js or anchor Development tools like this connect to the Solana network
    • Get the sub-account account object and use the getBalance() method to query the balance

Note:

  • Subaccount balances are stored in a different account than the parent account.
  • You can only query the balance of sub-accounts holding SPL tokens (such as SOL, SRM, RAY).
  • A small transaction fee is required to retrieve the sub-account balance.

The above is the detailed content of How to find sub-account balance in solana. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn