wrm3 / sol_xfr

Solana & Token Transfer For Python
2 stars 1 forks source link

Error with solders #1

Closed bennimen closed 4 months ago

bennimen commented 4 months ago

Amazing, thanks for this awesome share!

I'm getting a problem using this when using the solders library.

It seems that the Keypair function doesn't have the from_base58_string() function. When looking into it, it says that that maybe a Rust function.

Do you have a recommendation on how to get this working? or maybe a specific version for solders that you know this works with?

Been scouring for answers regarding this and yours is the first that I've come across. Thanks so much!

wrm3 commented 4 months ago

These are the versions of everything I have that I think might be related... Python 3.12.1 base58 2.1.1 solana 0.34.0 solders 0.21.0 spl-token 0.1.5

I am pretty sure that from_base58_string() method is current, I see it listed here... https://github.com/kevinheavey/solders/blob/main/python/solders/keypair.pyi

It looks like from_base58_string() was added in solder 0.21, ChatGPT offered this as an option for lower versions...

sol_xfr

bennimen commented 4 months ago

thank you!

after doing some digging, it definitely wasn't the code that was wrong. i was inputting an incorrectly formatted string into the base58 function.

bennimen commented 4 months ago

Also a quick update before I close the problem.

I had to update the code slightly on my version because I was receving and error before this with the response from the API.

I had to change how python interpretted the response, from client.get_balance(src_pubkey).value to client.get_balance(src_pubkey)['result']['value']:

src_bal                   = client.get_balance(src_pubkey)['result']['value'] / LAMPORTS
dest_pubkey               = Pubkey(base58.b58decode(dest_addr))
dest_bal                  = client.get_balance(dest_pubkey)['result']['value'] / LAMPORTS
send_amt_lamps            = int(amt_sol * LAMPORTS)

if show_details_yn == 'Y':
    WoG('Before Balances')
    # Show Before Balance in Source Account
    src_bal         = client.get_balance(src_pubkey)['result']['value'] / LAMPORTS
    G('{:<40} : {:>21.8f} SOL'.format('Source Wallet SOL balance', src_bal))
    # Show Before Balance in Destination Account
    dest_bal        = client.get_balance(dest_pubkey)['result']['value'] / LAMPORTS
    G('{:<40} : {:>21.8f} SOL'.format('Destination Wallet SOL balance', dest_bal))

specifically how the dictionary files accessed its keys and values

bennimen commented 4 months ago

Thank you again for this amazing code and your help!