Skip to main content
Glama

OKX-DEX-SDK MCP SSE Server

by 0xobedient
get_chain_data.ts•1.06 kB
import { createOKXClient } from "./../../shared/common/okxClient"; import { BaseWallet } from "./../../shared/common/wallet"; import { ENV } from "./../../shared/env"; import { APIResponse, ChainData, OKXDexClient } from "@okx-dex/okx-dex-sdk"; import { Connection, Keypair } from "@solana/web3.js"; import bs58 from "bs58"; export async function get_chain_data(chainId: string): Promise<string> { try { const connection = new Connection(ENV.RPC_ENDPOINT_URI); const keypair = Keypair.fromSecretKey(bs58.decode(ENV.WALLET_PRIVATE_KEY)); const baseWallet = new BaseWallet(keypair, connection); const client: OKXDexClient = createOKXClient(baseWallet); const chain_data: APIResponse<ChainData> = await client.dex.getChainData( chainId ); return JSON.stringify({ status: "success", data: chain_data, message: "OKX_DEX_GET_CHAIN_DATA_SUCCEEDED", }); } catch (error: any) { return JSON.stringify({ status: "error", error, message: "OKX_DEX_GET_CHAIN_DATA_ERROR", }); } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/0xobedient/okx-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server