'Connect to Serum Dex's order book updates using solana-py
I am trying to use Solana Py to connect to serum's dex and get order book updates. I am not sure how to do this. I had something working using serum-vial, but I'm trying to rewrite that library because it has caused me too many issues.
As a proof of concept, I am trying to get "SOL/USDC" to load in. So I am trying to get SOL/USDC's account info to load in the proper program Id. Here is my code:
import asyncio
from asyncstdlib import enumerate
from solana.rpc.websocket_api import connect
from solana.publickey import PublicKey
from solana.rpc.async_api import AsyncClient
from solana.rpc.commitment import Confirmed
async def main():
client = AsyncClient("https://psytrbhymqlkfrhudd.dev.genesysgo.net:8889/", Confirmed)
print("Connecting...")
await client.is_connected()
response = await client.get_account_info(
PublicKey("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),
encoding="base64"
)
for stake in response['result']:
print(stake)
await client.close()
asyncio.run(main())
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
