You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用Python解码Solana中get_account_info返回的Raydium池数据?

解码Solana Raydium池账户二进制数据问题

我正在使用Python操作Solana区块链,尝试解码账户请求(Raydium池)返回的二进制数据。当我通过以下代码请求账户信息时:

from solana.rpc.api import Client
from solders.pubkey import Pubkey
import json
import base64
solana_client = Client("https://thrilling-withered-sheet.solana-mainnet.quiknode.pro/a0d9c563e6ed34fa17d4b012518a593834fbc86e/")

resp_ = solana_client.get_account_info(Pubkey.from_string('EwxCuTua1op5drWWwYbAwnyWHgC5N5vo3HoESipVNTXA'), encoding='base64')
print(resp_)
resp = json.loads(resp_.to_json())
data_b64 = resp['result']['value']['data'][0]
data = base64.b64decode(data_b64)
print(data)

data字段包含一段长二进制序列,类似如下格式:

b"\x06\x00\x00\x00\x00\x00\x00\x00\xfe\x00\x00\x00\x00\x00\x00\x00\x07 ........\x00\x00\x00"

我需要解码该二进制序列以提取所需信息,如余额、代币合约及其他池专属数据,恳请指导以下问题:

  • 如何识别Raydium池及其他类型账户的数据结构
  • 可用于解码Solana账户数据的Python库或方法(如struct模块)
  • 是否存在可获取所需信息的公开API(我暂未找到)

感谢您提供任何建议或示例!

内容的提问来源于stack exchange,提问作者SerhiK

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 16:49:55