Skip to main content
Glama

prepareERC721SetApprovalForAll

Prepare transaction data for setting or revoking approval of all NFTs in an ERC721 contract to a specific operator address. This enables or disables bulk transfers of your NFTs by that operator.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contractAddressYes
operatorYes
approvedYes
fromAddressYes
providerNo
chainIdNo
gasLimitNo
gasPriceNo
maxFeePerGasNo
maxPriorityFeePerGasNo

Implementation Reference

  • The async handler function implementing the core logic of the 'prepareERC721SetApprovalForAll' tool. It retrieves NFT collection info, prepares gas options, calls ethersService.prepareERC721SetApprovalForAll to generate the unsigned transaction, and formats the response with transaction details in JSON.
          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.prepareERC721SetApprovalForAll(
              params.contractAddress,
              params.operator,
              params.approved,
              params.fromAddress,
              params.provider,
              params.chainId,
              options
            );
            
            return {
              content: [{ 
                type: "text", 
                text: `ERC721 Set Approval For All Transaction Prepared:
    
    Collection: ${nftInfo.name} (${nftInfo.symbol})
    Owner: ${params.fromAddress}
    Operator: ${params.operator}
    Approved: ${params.approved ? 'Yes' : 'No'}
    
    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 setApprovalForAll transaction: ${error instanceof Error ? error.message : String(error)}`
              }]
            };
          }
        }
  • The MCP server.tool registration call that registers the 'prepareERC721SetApprovalForAll' tool with its description, input schema, and handler reference.
        "prepareERC721SetApprovalForAll",
        "Prepare an ERC721 NFT setApprovalForAll transaction for signing. Returns transaction data that can be signed and broadcast.",
        {
          contractAddress: contractAddressSchema,
          operator: addressSchema,
          approved: z.boolean(),
          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.prepareERC721SetApprovalForAll(
              params.contractAddress,
              params.operator,
              params.approved,
              params.fromAddress,
              params.provider,
              params.chainId,
              options
            );
            
            return {
              content: [{ 
                type: "text", 
                text: `ERC721 Set Approval For All Transaction Prepared:
    
    Collection: ${nftInfo.name} (${nftInfo.symbol})
    Owner: ${params.fromAddress}
    Operator: ${params.operator}
    Approved: ${params.approved ? 'Yes' : 'No'}
    
    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 setApprovalForAll transaction: ${error instanceof Error ? error.message : String(error)}`
              }]
            };
          }
        }
      );
  • Input schema using Zod validators for the tool parameters: contract address, operator, approval status, from address, provider, chain ID, and optional gas parameters.
      contractAddress: contractAddressSchema,
      operator: addressSchema,
      approved: z.boolean(),
      fromAddress: addressSchema,
      provider: providerSchema,
      chainId: chainIdSchema,
      gasLimit: z.string().optional(),
      gasPrice: z.string().optional(),
      maxFeePerGas: z.string().optional(),
      maxPriorityFeePerGas: z.string().optional()
    },
    async (params) => {
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 only states it 'Returns transaction data that can be signed and broadcast.' It doesn't disclose that this is a read-only preparation step (not actually sending), what happens if parameters are invalid, whether it interacts with blockchain nodes, or any rate limits. The description adds minimal behavioral context beyond the basic purpose.

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 perfectly concise with two clear sentences that front-load the purpose and outcome. Every word earns its place with no redundancy or unnecessary elaboration.

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?

For a complex blockchain transaction preparation tool with 10 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain the relationship between preparation and execution tools, doesn't clarify parameter roles, and provides minimal behavioral context despite the tool's significant complexity and potential consequences.

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?

With 0% schema description coverage for 10 parameters (4 required), the description provides no information about any parameters. It doesn't explain what 'contractAddress', 'operator', 'approved', 'fromAddress', or the 6 optional gas/chain parameters mean or how they should be used, leaving significant gaps in understanding.

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

Purpose5/5

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

The description clearly states the specific action ('Prepare an ERC721 NFT setApprovalForAll transaction for signing') and the resource involved (ERC721 NFT transactions). It distinguishes from siblings like 'prepareERC721Approval' (single approval) and 'setNFTApprovalForAll' (likely the execution tool) by focusing on preparation rather than execution or different approval types.

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 when to choose this over 'prepareERC721Approval' (for single approvals) or 'setNFTApprovalForAll' (which might execute the transaction), nor does it specify prerequisites like needing a wallet loaded first.

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