I'm working on a Python script to pull successful transfers from the mint address. When I call the script below this is the error:
Traceback (most recent call last): File "/home/user/Documents/test12.py", line 13, in response = client.get_token_accounts_by_owner(mint_pubkey, opts=opts) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/.local/lib/python3.11/site-packages/solana/rpc/api.py", line 860, in get_token_accounts_by_owner body = self._get_token_accounts_by_owner_body(owner, opts, commitment) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/.local/lib/python3.11/site-packages/solana/rpc/core.py", line 422, in get_token_accounts_by_owner_body pubkey, filter, config = self._get_token_accounts_convert(owner, opts, commitment) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/.local/lib/python3.11/site-packages/solana/rpc/core.py", line 384, in _get_token_accounts_convert encoding_to_use = _ACCOUNT_ENCODING_TO_SOLDERS[opts.encoding] ^^^^^^^^^^^^^ AttributeError: 'dict' object has no attribute 'encoding'
from solana.rpc.api import Client
from solanasdk.publickey import PublicKey
# Initialize the Solana RPC client
client = Client("https://api.mainnet-beta.solana.com")
# Token Mint Address as a PublicKey
token_mint_address = "TOKENADDRESSHERE"
mint_pubkey = PublicKey(token_mint_address)
# Fetching token accounts by mint address
opts = {"mint": mint_pubkey}
response = client.get_token_accounts_by_owner(mint_pubkey, opts=opts)
I thought I would be getting a string, not a dict back. I saw a reference somewhere that said if you are not passing a PublicKey for the mint address (passing its string instead) then this would happen. I am passing the mint address as a PublicKey.