AsyncClient object has no attribute decode_transfer - solana.py

84 Views Asked by At

I'm trying to get the instruction data in solana.py..

https://michaelhly.com/solana-py/rpc/async_api/#solana.rpc.async_api.AsyncClient

I use the above page in my program and work on the necessary details. Anyway I need some details from the "instruction data" so I'm reading this docs,

https://michaelhly.com/solana-py/spl/token/instructions/#spl.token.instructions.decode_transfer

When I try to work on the below code,

async def main():
    async with AsyncClient("https://api.mainnet-beta.solana.com") as client:
        v_a = (await client.decode_transfer(instruction)).value
        print(v_a)

It say AttributeError:

'AsyncClient' object has no attribute 'decode_transfer'

Can anyone help me and say what am I doing wrong here?

I tried to work on adding different import statements by reading the documentation and i cannot solve the problem..I want to get the details of the instruction data and get the "amount in" value..thanks in advance for any help!

1

There are 1 best solutions below

0
Amir Abdollahi On

I haven't used Solana myself, but this is what I found, hope it helps :)

from solana.rpc.async_api import AsyncClient
from spl.token.instructions import decode_transfer

async def main():
    async with AsyncClient("https://api.mainnet-beta.solana.com") as client:
        decoded_transfer = decode_transfer(instruction_data)
        print(decoded_transfer)