UNPKG

cotiv2-mcp

Version:

> A plug-and-play MCP tool server to **send COTI**, **transfer BEP-20 tokens**, **deploy tokens**, and **interact with smart contracts** on the **COTI v2 Network (COTI)** — built for **Claude Desktop**, **AI agents**, and **developers.**

32 lines (31 loc) 986 B
import { getDefaultProvider, Wallet, } from "@coti-io/coti-ethers"; import { toHex } from "viem"; import { configureStorage, getStorage } from "./storage.js"; export async function setupAccountFromPk(pk, network) { const provider = getDefaultProvider(network); const wallet = new Wallet(pk, provider); let userKey = (await getStorage()).WALLET_AES_KEY; const toAccount = async (wallet, userKey) => { if (userKey) { wallet.setAesKey(userKey); return wallet; } await wallet.generateOrRecoverAes(); return wallet; }; let account; if (!userKey) { account = await toAccount(wallet); await configureStorage({ WALLET_AES_KEY: account.getUserOnboardInfo()?.aesKey, }); } else { account = await toAccount(wallet, userKey); } return account; } export const toField = (obj) => ({ ciphertext: obj.ciphertext, signature: toHex(obj.signature), });