Я создаю скрипт Python для вывода Raffles с сайта Solana NFT лотереи https://rafffle.famousfoxes.com/образнойimport asyncio
import json
from anchorpy import Provider, Program, Idl
from solana.rpc.async_api import AsyncClient
from solders.pubkey import Pubkey
async def main():
# Connect to the cluster
client = AsyncClient("") # RPC endpoint here
provider = Provider(client, None)
# Load the IDL from your file
with open("SolanaIDL.json", "r") as f:
idl_json_str = f.read()
idl = Idl.from_json(idl_json_str)
# Use the program ID from your IDL
program_id = Pubkey.from_string("9ehXDD5bnhSpFVRf99veikjgq8VajtRH7e3D9aVPLqYd")
program = Program(idl, program_id, provider)
try:
print(f"Program ID: {program_id}")
print(f"Program name from IDL: {idl.name}")
# Fetch all accounts of type "raffle"
print("Attempting to fetch raffle accounts...")
raffle_accounts = await program.account["raffle"].all()
if not raffle_accounts:
print("No raffle accounts found.")
print("Debug info:")
print(f"- Network: {client._provider.endpoint_uri}")
print(f"- Program ID: {program_id}")
# Add connection test
print("\nTesting connection...")
slot = await client.get_slot()
print(f"Current slot: {slot}")
else:
print(f"Found {len(raffle_accounts)} raffle accounts")
print(raffle_accounts)
except Exception as e:
print(f"Error fetching raffle data: {e}")
finally:
await client.close()
if __name__ == "__main__":
asyncio.run(main())
< /code>
Я ожидал, что он выведет список raffle_accounts, но список был пуст, поэтому он вышел следующее: < /p>
Program ID: 9ehXDD5bnhSpFVRf99veikjgq8VajtRH7e3D9aVPLqYd
Program name from IDL: rafffle
Attempting to fetch raffle accounts...
No raffle accounts found.
Debug info:
- Network: https://mainnet.helius-rpc.com/###
- Program ID: 9ehXDD5bnhSpFVRf99veikjgq8VajtRH7e3D9aVPLqYd
Testing connection...
Current slot: GetSlotResp(317701589)
< /code>
Мой вопрос: почему raffle_accounts - пустой список, а не наполнен фактической информацией лотереи? Там, где правильные, это действительно должно вывозить raffle_accounts. Что я смотрю? 44E6-8217-6ED604A54630#OYV5PACHHMM3GIGN8OGO2Z6OQXBKN4ZMIAOXZTSL32C
Подробнее здесь: https://stackoverflow.com/questions/794 ... ith-an-idl
Как просмотреть данные и выполнить действия в программе Solana с помощью IDP? ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение