Skip to main content
Glama
viem.ts791 B
import { type Chain, extractChain, http, createPublicClient, createWalletClient, publicActions, } from "viem"; import { privateKeyToAccount } from "viem/accounts"; import * as chains from "viem/chains"; const chainsList = Object.values(chains); export const getChainById = (id: number): Chain => { return extractChain({ chains: chainsList, id: id as (typeof chainsList)[number]["id"], }); }; export const createClient = (chain: Chain, privateKey?: `0x${string}`) => { if (privateKey) { return createWalletClient({ account: privateKeyToAccount(privateKey), chain, transport: http(), }).extend(publicActions); } return createPublicClient({ chain: chain, transport: http(), batch: { multicall: true, }, }); };

Latest Blog Posts

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/EmanuelJr/web3-mcp-server'

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