Skip to main content
Glama
Transfer.ts862 B
import { z } from "zod"; import { type WalletClient, parseUnits } from "viem"; import { createClient, getChainById } from "../viem"; export const TransferSchema = z.object({ chainId: z.number(), recipientAddress: z.string().startsWith("0x"), amount: z.string(), }); export type TransferOptions = z.infer<typeof TransferSchema>; export const transfer = async (options: TransferOptions) => { const { chainId, recipientAddress, amount } = options; const chain = getChainById(chainId); const walletClient = createClient( chain, process.env.PRIVATE_KEY as `0x${string}` ) as WalletClient; const tx = await walletClient.sendTransaction({ to: recipientAddress as `0x${string}`, value: parseUnits(amount, chain.nativeCurrency.decimals), account: walletClient.account ?? null, chain, }); return { txHash: tx, }; };

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