Skip to main content
Glama

prepareERC721Approval

Generate transaction data to authorize another address to transfer a specific ERC721 NFT token on your behalf, ready for signing and broadcasting.

Instructions

Prepare an ERC721 NFT approval transaction for signing. Returns transaction data that can be signed and broadcast.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contractAddressYes
tokenIdYes
approvedAddressYes
fromAddressYes
providerNo
chainIdNo
gasLimitNo
gasPriceNo
maxFeePerGasNo
maxPriorityFeePerGasNo

Implementation Reference

  • The main handler function for the 'prepareERC721Approval' MCP tool. It fetches NFT collection info, prepares gas options, calls ethersService.prepareERC721Approval to get the unsigned transaction request, formats it as JSON, and returns it in the MCP response format.
        async (params) => {
          try {
            // Get NFT collection info for display
            const nftInfo = await ethersService.getERC721CollectionInfo(
              params.contractAddress,
              params.provider,
              params.chainId
            );
            
            // Prepare gas options
            const options = {
              gasLimit: params.gasLimit,
              gasPrice: params.gasPrice,
              maxFeePerGas: params.maxFeePerGas,
              maxPriorityFeePerGas: params.maxPriorityFeePerGas
            };
            
            const txRequest = await ethersService.prepareERC721Approval(
              params.contractAddress,
              params.approvedAddress,
              params.tokenId,
              params.fromAddress,
              params.provider,
              params.chainId,
              options
            );
            
            return {
              content: [{ 
                type: "text", 
                text: `ERC721 Approval Transaction Prepared:
    
    Collection: ${nftInfo.name} (${nftInfo.symbol})
    Token ID: ${params.tokenId}
    Owner: ${params.fromAddress}
    Approved Address: ${params.approvedAddress}
    
    Transaction Data:
    ${JSON.stringify({
      to: txRequest.to,
      data: txRequest.data,
      value: txRequest.value || "0",
      gasLimit: txRequest.gasLimit?.toString(),
      gasPrice: txRequest.gasPrice?.toString(),
      maxFeePerGas: txRequest.maxFeePerGas?.toString(),
      maxPriorityFeePerGas: txRequest.maxPriorityFeePerGas?.toString(),
      chainId: txRequest.chainId
    }, null, 2)}
    
    This transaction is ready to be signed and broadcast.`
              }]
            };
          } catch (error) {
            return {
              isError: true,
              content: [{ 
                type: "text", 
                text: `Error preparing NFT approval transaction: ${error instanceof Error ? error.message : String(error)}`
              }]
            };
          }
        }
  • Zod schema defining the input parameters for the prepareERC721Approval tool, including contract details, addresses, chain info, and optional gas parameters.
    {
      contractAddress: contractAddressSchema,
      tokenId: tokenIdSchema,
      approvedAddress: addressSchema,
      fromAddress: addressSchema,
      provider: providerSchema,
      chainId: chainIdSchema,
      gasLimit: z.string().optional(),
      gasPrice: z.string().optional(),
      maxFeePerGas: z.string().optional(),
      maxPriorityFeePerGas: z.string().optional()
    },
  • Registration of the prepareERC721Approval tool with the MCP server using server.tool(), including name, description, schema, and handler.
        "prepareERC721Approval",
        "Prepare an ERC721 NFT approval transaction for signing. Returns transaction data that can be signed and broadcast.",
        {
          contractAddress: contractAddressSchema,
          tokenId: tokenIdSchema,
          approvedAddress: addressSchema,
          fromAddress: addressSchema,
          provider: providerSchema,
          chainId: chainIdSchema,
          gasLimit: z.string().optional(),
          gasPrice: z.string().optional(),
          maxFeePerGas: z.string().optional(),
          maxPriorityFeePerGas: z.string().optional()
        },
        async (params) => {
          try {
            // Get NFT collection info for display
            const nftInfo = await ethersService.getERC721CollectionInfo(
              params.contractAddress,
              params.provider,
              params.chainId
            );
            
            // Prepare gas options
            const options = {
              gasLimit: params.gasLimit,
              gasPrice: params.gasPrice,
              maxFeePerGas: params.maxFeePerGas,
              maxPriorityFeePerGas: params.maxPriorityFeePerGas
            };
            
            const txRequest = await ethersService.prepareERC721Approval(
              params.contractAddress,
              params.approvedAddress,
              params.tokenId,
              params.fromAddress,
              params.provider,
              params.chainId,
              options
            );
            
            return {
              content: [{ 
                type: "text", 
                text: `ERC721 Approval Transaction Prepared:
    
    Collection: ${nftInfo.name} (${nftInfo.symbol})
    Token ID: ${params.tokenId}
    Owner: ${params.fromAddress}
    Approved Address: ${params.approvedAddress}
    
    Transaction Data:
    ${JSON.stringify({
      to: txRequest.to,
      data: txRequest.data,
      value: txRequest.value || "0",
      gasLimit: txRequest.gasLimit?.toString(),
      gasPrice: txRequest.gasPrice?.toString(),
      maxFeePerGas: txRequest.maxFeePerGas?.toString(),
      maxPriorityFeePerGas: txRequest.maxPriorityFeePerGas?.toString(),
      chainId: txRequest.chainId
    }, null, 2)}
    
    This transaction is ready to be signed and broadcast.`
              }]
            };
          } catch (error) {
            return {
              isError: true,
              content: [{ 
                type: "text", 
                text: `Error preparing NFT approval transaction: ${error instanceof Error ? error.message : String(error)}`
              }]
            };
          }
        }
      );
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 mentions the tool 'returns transaction data that can be signed and broadcast,' which clarifies it's a preparation step (non-destructive) and not an execution. However, it doesn't disclose critical behavioral traits like required permissions, gas estimation, network dependencies, or error handling for the 10 parameters.

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?

Two sentences, front-loaded with the core purpose and followed by the return value. Zero waste—every word earns its place, making it efficient and easy to parse.

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 high complexity (10 parameters, 0% schema coverage, no annotations, no output schema), the description is incomplete. It lacks details on parameter usage, behavioral context (e.g., network effects, signing requirements), and doesn't explain the return format beyond 'transaction data,' leaving gaps for a tool with many inputs.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate. It adds no meaning beyond the schema—no explanation of what parameters like 'provider', 'chainId', or gas fields do, or how they interact. The description only implies parameters through 'ERC721 NFT approval,' but doesn't detail semantics for any of the 10 parameters.

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 verb ('prepare') and resource ('ERC721 NFT approval transaction'), specifying it's for signing and returns transaction data. It distinguishes from siblings like 'approveNFT' (which might execute) and 'setNFTApprovalForAll' (which is for all tokens), but doesn't explicitly contrast with 'prepareERC721SetApprovalForAll' (for all approvals).

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?

No guidance on when to use this tool versus alternatives like 'prepareERC721SetApprovalForAll' (for batch approvals) or 'approveNFT' (which might execute directly). The description implies it's for preparing a single NFT approval transaction, but lacks explicit context or exclusions.

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

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/crazyrabbitLTC/mcp-ethers-server'

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