Skip to main content
Glama

wallet_encrypt

Encrypt Ethereum and EVM-compatible wallets using a password to secure private keys, mnemonics, or JSON files, with optional custom scrypt parameters.

Instructions

Encrypt a wallet with a password

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
optionsNoOptional encryption options
passwordYesThe password to encrypt the wallet
walletYesThe wallet to encrypt (private key, mnemonic, or JSON)

Implementation Reference

  • The encryptWalletHandler function implements the core logic for the wallet_encrypt tool. It retrieves a wallet using getWallet, encrypts it with the provided password and options using ethers.Wallet.encrypt, and returns the encrypted wallet JSON.
    export const encryptWalletHandler = async (input: any): Promise<ToolResultSchema> => {
      try {
        if (!input.wallet) {
          return createErrorResponse("Wallet is required");
        }
    
        if (!input.password) {
          return createErrorResponse("Password is required");
        }
    
        const wallet = await getWallet(input.wallet);
        const encryptedWallet = await wallet.encrypt(input.password, input.options);
    
        return createSuccessResponse(
        `Wallet encrypted successfully
          Encrypted Wallet: ${encryptedWallet}
        `);
      } catch (error) {
        return createErrorResponse(`Failed to encrypt wallet: ${(error as Error).message}`);
      }
    };
  • Input schema definition for the wallet_encrypt tool, specifying the required wallet and password parameters, along with optional scrypt encryption options.
    {
      name: "wallet_encrypt",
      description: "Encrypt a wallet with a password",
      inputSchema: {
        type: "object",
        properties: {
          wallet: { type: "string", description: "The wallet to encrypt (private key, mnemonic, or JSON)" },
          password: { type: "string", description: "The password to encrypt the wallet" },
          options: { 
            type: "object", 
            description: "Optional encryption options",
            properties: {
              scrypt: {
                type: "object",
                properties: {
                  N: { type: "number" },
                  r: { type: "number" },
                  p: { type: "number" }
                }
              }
            }
          }
        },
        required: ["wallet", "password"]
      }
    },
  • src/tools.ts:556-608 (registration)
    The handlers dictionary registers 'wallet_encrypt' key mapped to the encryptWalletHandler function, which is used by the MCP server to dispatch calls to the correct implementation.
    export const handlers: HandlerDictionary = {
      // Provider Methods
      "wallet_provider_set": setProviderHandler,
      // Wallet Creation and Management
      "wallet_create_random": createWalletHandler,
      "wallet_from_private_key": fromPrivateKeyHandler,
      "wallet_from_mnemonic": fromMnemonicHandler,
      "wallet_from_encrypted_json": fromEncryptedJsonHandler,
      "wallet_encrypt": encryptWalletHandler,
    
      // Wallet Properties
      "wallet_get_address": getAddressHandler,
      "wallet_get_public_key": getPublicKeyHandler,
      "wallet_get_private_key": getPrivateKeyHandler,
    
      // Blockchain Methods
      "wallet_get_balance": getBalanceHandler,
      "wallet_get_chain_id": getChainIdHandler,
      "wallet_get_gas_price": getGasPriceHandler,
      "wallet_get_transaction_count": getTransactionCountHandler,
      "wallet_call": callHandler,
    
      // Transaction Methods
      "wallet_send_transaction": sendTransactionHandler,
      "wallet_sign_transaction": signTransactionHandler,
      "wallet_populate_transaction": populateTransactionHandler,
    
      // Signing Methods
      "wallet_sign_message": signMessageHandler,
      "wallet_sign_typed_data": signTypedDataHandler,
      "wallet_verify_message": verifyMessageHandler,
      "wallet_verify_typed_data": verifyTypedDataHandler,
    
      // Provider Methods
      "provider_get_block": getBlockHandler,
      "provider_get_transaction": getTransactionHandler,
      "provider_get_transaction_receipt": getTransactionReceiptHandler,
      "provider_get_code": getCodeHandler,
      "provider_get_storage_at": getStorageAtHandler,
      "provider_estimate_gas": estimateGasHandler,
      "provider_get_logs": getLogsHandler,
      "provider_get_ens_resolver": getEnsResolverHandler,
      "provider_lookup_address": lookupAddressHandler,
      "provider_resolve_name": resolveNameHandler,
    
      // Network Methods
      "network_get_network": getNetworkHandler,
      "network_get_block_number": getBlockNumberHandler,
      "network_get_fee_data": getFeeDataHandler,
    
      // Mnemonic Methods
      "wallet_create_mnemonic_phrase": createMnemonicPhraseHandler
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states the tool encrypts but doesn't disclose critical traits: whether encryption is irreversible without the password, what format the output takes (e.g., JSON string), if it modifies the original wallet or returns a new one, or any side effects like requiring specific permissions. For a security-sensitive operation, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core action ('Encrypt a wallet'), making it easy to parse quickly. Every word earns its place by contributing to the basic purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (encryption with nested options), lack of annotations, and no output schema, the description is incomplete. It doesn't explain the output format, security implications, error conditions, or how 'options' customize encryption. For a tool that handles sensitive data, this leaves significant gaps for an agent to operate safely.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so parameters are documented in the schema itself. The description adds no extra meaning beyond implying 'wallet' and 'password' are required (which the schema already shows). It doesn't clarify parameter interactions (e.g., how 'options' affect encryption) or provide examples, so it meets the baseline but doesn't enhance understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('encrypt') and target ('a wallet') with the mechanism ('with a password'), making the purpose immediately understandable. It doesn't differentiate from siblings like 'wallet_from_encrypted_json' (which decrypts) or 'wallet_create_random' (which creates), but the verb+resource combination is specific enough for basic understanding.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an unencrypted wallet first), compare to siblings like 'wallet_from_encrypted_json' (for decryption), or specify use cases (e.g., securing a wallet for storage). Without this context, an agent might misuse it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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