Get the best brings on solana with python
As a developer, it is essential to have access to the best wallets of a particular token on a blockchain Network Like Solana. In this article, we will explore how to use python and the library solana.py
to achieve this.
What are the program accounts?
The program accounts are the native tokens owned by the sol programs (Solana). They represent the funds used for the distribution and management of programs on the solana network. To obtain the best owners or account account hollowers, we must identify which wallets contain a significant part of these tokens.
The function get_programm_accounts
In the bookshop Solana.py
, the function ‘get_programm_acounts ()It is part of the split' module, which provides access to SPL accounts (interface of the solana program). This function allows us to recover the program accounts associated with specific token addresses.
Python
From solana.py import account_info, System_program
Def Get_top_Progrophrogram_cacount_holders (token: Str):
"" ""
Recover the best program owners of the program for a specific token.
Args:
Token (str): The Address of the Solana Program That Has Tokens.
Return:
Dict: a dictionary in which the keys are addresses and values of the portfolio are the accounts of the corresponding program.
"" ""
Get the Program Associated With The Token Accounts Accounts
Account = System_program.get_Account_info (token). Account
Filter unscheduled accounts
Programs = [account for account in account If Isinance (account, account_info.accountinfo)]
Initialize An Empty Dictionary to Store the Best Owners
Top_Holters = {}
Iterate the program accounts and update the dictionary
For the program in programs:
wallet_address = account_info.get_programm_acount_info (program). Address
If wallet_address not in top_holders or sums (top_holders [wallet_address] / len (programms))> 0.8:
regulates the threshold if necessary
Top_HOLDERS [Wallet_address] = Program
Return Top_Holters
Example of Use
We use this function to obtain the main account hollowers of the token program SPL
.
`Python
Token = "your_solana_programm_address"
Top_HOLDERS = Get_TOP_Programm_cacount_holders (token)
Print (TOP_HOLDERS)
Replace " your_solana_programm_address "
With your address of the solana program. The resulting dictionary will contain the addresses of the portfolio as keys and their corresponding program accounts as values.
NOTE
: This function has a time limit of 30 minutes per call, so it is essential to check the latency of the solana network before making great demands. If you need more information or adjustments to this threshold, consultation the [solana documentation] (