Skip to main content
Glama

unwrap_wedu

Convert Wrapped EDU (WEDU) back to EDU on the EDUCHAIN network using your wallet's private key and the specified amount of WEDU.

Instructions

Unwrap WEDU (Wrapped EDU) to EDU

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountYesAmount of WEDU to unwrap
privateKeyYesPrivate key of the wallet

Implementation Reference

  • Core handler function that executes the unwrap logic: checks WEDU balance, calls withdraw on WETH9 contract, returns transaction details.
    export async function unwrapWEDU(
      privateKey: string,
      amount: string
    ): Promise<{
      hash: string;
      from: string;
      amount: string;
      success: boolean;
    }> {
      try {
        const provider = blockchain.getProvider();
        const wallet = new ethers.Wallet(privateKey, provider);
        const fromAddress = wallet.address;
        
        // Convert WEDU amount to wei
        const amountInWei = ethers.parseEther(amount);
        
        // Create WETH9 contract instance
        const wethAbi = [
          'function deposit() external payable',
          'function withdraw(uint256 amount) external',
          'function balanceOf(address owner) view returns (uint256)',
          'function approve(address spender, uint256 amount) external returns (bool)'
        ];
        
        const wethContract = new ethers.Contract(CONTRACTS.WETH9, wethAbi, wallet);
        
        // Check balance
        const balance = await wethContract.balanceOf(fromAddress);
        if (balance < amountInWei) {
          throw new Error(`Insufficient WEDU balance. You have ${ethers.formatEther(balance)} WEDU, but tried to unwrap ${amount} WEDU.`);
        }
        
        // Withdraw WEDU to get EDU
        const tx = await wethContract.withdraw(amountInWei);
        const receipt = await tx.wait();
        
        if (!receipt) {
          throw new Error('Transaction failed');
        }
        
        return {
          hash: tx.hash,
          from: fromAddress,
          amount,
          success: true
        };
      } catch (error) {
        console.error('Error unwrapping WEDU to EDU:', error);
        throw error;
      }
    }
  • Input schema definition for the unwrap_wedu tool, specifying parameters privateKey and amount.
      name: 'unwrap_wedu',
      description: 'Unwrap WEDU (Wrapped EDU) to EDU',
      inputSchema: {
        type: 'object',
        properties: {
          privateKey: {
            type: 'string',
            description: 'Private key of the wallet',
          },
          amount: {
            type: 'string',
            description: 'Amount of WEDU to unwrap',
          },
        },
        required: ['privateKey', 'amount'],
      },
    },
  • src/index.ts:1442-1479 (registration)
    MCP tool registration and dispatch handler: validates inputs, calls swap.unwrapWEDU, formats response with success/error handling.
    case 'unwrap_wedu': {
      if (!args.privateKey || typeof args.privateKey !== 'string') {
        throw new McpError(ErrorCode.InvalidParams, 'Private key is required');
      }
      
      if (!args.amount || typeof args.amount !== 'string') {
        throw new McpError(ErrorCode.InvalidParams, 'Amount is required');
      }
      
      try {
        const result = await swap.unwrapWEDU(args.privateKey, args.amount);
        
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                ...result,
                message: `Successfully unwrapped ${args.amount} WEDU to EDU`,
              }, null, 2),
            },
          ],
        };
      } catch (error) {
        console.error('Error unwrapping WEDU to EDU:', error);
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({ 
                error: 'Failed to unwrap WEDU to EDU',
                message: (error as Error).message
              }, null, 2),
            },
          ],
          isError: true,
        };
      }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the action ('Unwrap') but doesn't disclose behavioral traits such as whether this is a blockchain transaction (implying gas fees, confirmation time), if it's irreversible, what permissions are needed, or potential errors (e.g., insufficient balance). The description is minimal and lacks critical operational context.

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 extremely concise with a single, direct sentence that front-loads the core action. There is zero wasted verbiage or redundancy, making it efficient for quick comprehension, though this conciseness comes at the cost of completeness.

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 of a blockchain token conversion tool with no annotations and no output schema, the description is incomplete. It lacks details on what EDU/WEDU are, the transaction nature, expected outputs, error handling, or integration context. For a tool that likely involves sensitive operations (private key usage) and financial implications, this minimal description is inadequate.

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%, with clear parameter descriptions in the schema ('Amount of WEDU to unwrap', 'Private key of the wallet'). The tool description adds no additional parameter semantics beyond what's in the schema, such as format details (e.g., amount in wei/tokens) or security considerations for the private key. Baseline 3 is appropriate given high schema coverage.

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 ('Unwrap') and the resource ('WEDU to EDU'), making the purpose understandable. It distinguishes from sibling 'wrap_edu' by indicating the opposite conversion direction. However, it doesn't specify what WEDU/EDU are (tokens, assets) or the platform context, leaving some ambiguity.

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 WEDU balance), compare to other conversion tools like 'swap_edu_for_tokens', or indicate typical use cases (e.g., redeeming wrapped tokens). Usage is implied from the name but not explicitly stated.

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/SailFish-Finance/educhain-ai-agent-kit'

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