Skip to main content
Glama

bnbchain-mcp

Official
by bnb-chain
contracts.ts1.54 kB
import { type GetLogsParameters, type Hash, type Hex, type Log, type ReadContractParameters } from "viem" import { getPublicClient, getWalletClient } from "./clients.js" import { resolveAddress } from "./ens.js" /** * Read from a contract for a specific network */ export async function readContract( params: ReadContractParameters, network = "ethereum" ) { const client = getPublicClient(network) return await client.readContract(params) } /** * Write to a contract for a specific network */ export async function writeContract( privateKey: Hex, params: Record<string, any>, network = "ethereum" ): Promise<Hash> { const client = getWalletClient(privateKey, network) return await client.writeContract(params as any) } /** * Get logs for a specific network */ export async function getLogs( params: GetLogsParameters, network = "ethereum" ): Promise<Log[]> { const client = getPublicClient(network) return await client.getLogs(params) } /** * Check if an address is a contract * @param addressOrEns Address or ENS name to check * @param network Network name or chain ID * @returns True if the address is a contract, false if it's an EOA */ export async function isContract( addressOrEns: string, network = "ethereum" ): Promise<boolean> { // Resolve ENS name to address if needed const address = await resolveAddress(addressOrEns, network) const client = getPublicClient(network) const code = await client.getCode({ address }) return code !== undefined && code !== "0x" }

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/bnb-chain/bnbchain-mcp'

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