Skip to main content
Glama

wallet_from_private_key

Generate a wallet for Ethereum and EVM-compatible blockchains using a private key with the MCP Crypto Wallet EVM server. Enables wallet creation for blockchain operations.

Instructions

Create a wallet from a private key

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
privateKeyYesThe private key

Implementation Reference

  • The core handler function that implements the wallet_from_private_key tool logic using ethers.Wallet.
    export const fromPrivateKeyHandler = async (input: fromPrivateKeyHandlerInput): Promise<ToolResultSchema> => {
      try {
        if (!input.privateKey) {
          return createErrorResponse("Private key is required");
        }
    
        const provider = getProvider()
        const wallet = new ethers.Wallet(input.privateKey, provider);
    
        return createSuccessResponse(
        `Wallet created from private key successfully:
          Address: ${wallet.address}
          Private Key: ${wallet.privateKey}
          Public Key: ${wallet.publicKey}
        `);
      } catch (error) {
        return createErrorResponse(`Failed to create wallet from private key: ${(error as Error).message}`);
      }
    };
  • MCP tool schema definition with input validation for the privateKey parameter.
    {
      name: "wallet_from_private_key",
      description: "Create a wallet from a private key",
      inputSchema: {
        type: "object",
        properties: {
          privateKey: { type: "string", description: "The private key" }
        },
        required: ["privateKey"]
      }
    },
  • src/tools.ts:561-561 (registration)
    Registration of the tool name to its handler function in the handlers dictionary.
    "wallet_from_private_key": fromPrivateKeyHandler,
  • TypeScript type definition for the input parameters used in the handler.
    export type fromPrivateKeyHandlerInput = {
      privateKey: string;
      provider?: string;
    };

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/dcSpark/mcp-cryptowallet-evm'

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