Skip to main content
Glama

prepareERC1155SetApprovalForAll

Prepare transaction data to approve or revoke an operator's access to all your ERC1155 tokens from a specific contract for signing and broadcasting.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contractAddressYesThe address of the ERC1155 contract
tokenAddressNoDEPRECATED: Use contractAddress instead. The address of the ERC1155 contract
operatorYesThe address to approve/revoke for all tokens
approvedYesWhether to approve (true) or revoke (false)
fromAddressYesThe address that owns the tokens
providerNoOptional. Either a network name or custom RPC URL. Use getAllNetworks to see available networks and their details, or getNetwork to get info about a specific network. You can use any network name returned by these tools as a provider value.
chainIdNoOptional. The chain ID to use.
gasLimitNo
gasPriceNo
maxFeePerGasNo
maxPriorityFeePerGasNo

Implementation Reference

  • The main handler function for the 'prepareERC1155SetApprovalForAll' tool. It processes parameters (mapping deprecated fields), prepares gas options, delegates to ethersService for transaction preparation, formats the unsigned transaction details, and handles errors.
        async (params) => {
          // Map deprecated parameters
          const mapped = mapParameters(params);
          
          try {
            const contractAddr = mapped.contractAddress || params.tokenAddress;
            if (!contractAddr) {
              throw new Error('Either contractAddress or tokenAddress must be provided');
            }
    
            // Prepare gas options
            const options = {
              gasLimit: params.gasLimit,
              gasPrice: params.gasPrice,
              maxFeePerGas: params.maxFeePerGas,
              maxPriorityFeePerGas: params.maxPriorityFeePerGas
            };
            
            const txRequest = await ethersService.prepareERC1155SetApprovalForAll(
              contractAddr,
              mapped.operator,
              params.approved,
              mapped.fromAddress,
              mapped.provider,
              mapped.chainId,
              options
            );
            
            return {
              content: [{ 
                type: "text", 
                text: `ERC1155 Set Approval For All Transaction Prepared:
    
    Contract: ${contractAddr}
    Owner: ${mapped.fromAddress}
    Operator: ${mapped.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 ERC1155 setApprovalForAll transaction: ${error instanceof Error ? error.message : String(error)}`
              }]
            };
          }
        }
      );
  • Input schema using Zod validation for the tool parameters, including contract address, operator, approval status, owner, provider options, and gas parameters.
      contractAddress: contractAddressSchema,
      tokenAddress: tokenAddressSchema.optional(),  // Deprecated
      operator: addressSchema.describe("The address to approve/revoke for all tokens"),
      approved: z.boolean().describe("Whether to approve (true) or revoke (false)"),
      fromAddress: addressSchema.describe("The address that owns the tokens"),
      provider: providerSchema,
      chainId: chainIdSchema,
      gasLimit: z.string().optional(),
      gasPrice: z.string().optional(),
      maxFeePerGas: z.string().optional(),
      maxPriorityFeePerGas: z.string().optional()
    },
  • The server.tool call that registers the 'prepareERC1155SetApprovalForAll' tool with the MCP server, including description, input schema, and handler function.
      server.tool(
        "prepareERC1155SetApprovalForAll",
        "Prepare an ERC1155 setApprovalForAll transaction for signing. Returns transaction data that can be signed and broadcast.",
        {
          contractAddress: contractAddressSchema,
          tokenAddress: tokenAddressSchema.optional(),  // Deprecated
          operator: addressSchema.describe("The address to approve/revoke for all tokens"),
          approved: z.boolean().describe("Whether to approve (true) or revoke (false)"),
          fromAddress: addressSchema.describe("The address that owns the tokens"),
          provider: providerSchema,
          chainId: chainIdSchema,
          gasLimit: z.string().optional(),
          gasPrice: z.string().optional(),
          maxFeePerGas: z.string().optional(),
          maxPriorityFeePerGas: z.string().optional()
        },
        async (params) => {
          // Map deprecated parameters
          const mapped = mapParameters(params);
          
          try {
            const contractAddr = mapped.contractAddress || params.tokenAddress;
            if (!contractAddr) {
              throw new Error('Either contractAddress or tokenAddress must be provided');
            }
    
            // Prepare gas options
            const options = {
              gasLimit: params.gasLimit,
              gasPrice: params.gasPrice,
              maxFeePerGas: params.maxFeePerGas,
              maxPriorityFeePerGas: params.maxPriorityFeePerGas
            };
            
            const txRequest = await ethersService.prepareERC1155SetApprovalForAll(
              contractAddr,
              mapped.operator,
              params.approved,
              mapped.fromAddress,
              mapped.provider,
              mapped.chainId,
              options
            );
            
            return {
              content: [{ 
                type: "text", 
                text: `ERC1155 Set Approval For All Transaction Prepared:
    
    Contract: ${contractAddr}
    Owner: ${mapped.fromAddress}
    Operator: ${mapped.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 ERC1155 setApprovalForAll transaction: ${error instanceof Error ? error.message : String(error)}`
              }]
            };
          }
        }
      );
  • Supporting helper function in ERC1155 service that executes the signed setApprovalForAll transaction. The tool's prepare version likely uses a similar approach but with populateTransaction to prepare unsigned tx data.
    export async function setApprovalForAll(
      ethersService: EthersService,
      contractAddress: string,
      operatorAddress: string,
      approved: boolean,
      provider?: string,
      chainId?: number,
      options: TokenOperationOptions = {}
    ): Promise<ethers.TransactionResponse> {
      metrics.incrementCounter('erc1155.setApprovalForAll');
      
      return timeAsync('erc1155.setApprovalForAll', async () => {
        try {
          // Get signer from ethers service
          const signer = ethersService['getSigner'](provider, chainId);
          
          // Create contract instance with signer
          const contractWithSigner = new ethers.Contract(contractAddress, ERC1155_ABI, signer);
          
          // Prepare transaction overrides
          const overrides: ethers.Overrides = {};
          if (options.gasLimit) overrides.gasLimit = options.gasLimit;
          if (options.gasPrice) overrides.gasPrice = options.gasPrice;
          if (options.maxFeePerGas) overrides.maxFeePerGas = options.maxFeePerGas;
          if (options.maxPriorityFeePerGas) overrides.maxPriorityFeePerGas = options.maxPriorityFeePerGas;
          if (options.nonce !== undefined) overrides.nonce = options.nonce;
          
          // Set approval
          const tx = await contractWithSigner.setApprovalForAll(operatorAddress, approved, overrides);
          
          return tx;
        } catch (error) {
          logger.debug('Error setting ERC1155 approval', { contractAddress, operatorAddress, approved, error });
          throw handleTokenError(error, 'Failed to set token approval');
        }
      });
    }
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 critical behavioral traits like whether this requires wallet connectivity, what happens if parameters are invalid, error conditions, or how the returned data should be used with signing/broadcast tools. For a transaction preparation tool with 11 parameters, this is insufficient.

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 with zero waste: first states the action and target, second states the return value and its purpose. Every word earns its place, and the most important information (what it does and what it returns) is front-loaded.

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 transaction preparation tool with 11 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain the workflow (how the returned data integrates with signing/broadcasting), error handling, or behavioral constraints. The agent would struggle to use this tool correctly without additional context.

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 64%, so the description must compensate but adds no parameter-specific information beyond what's implied by the tool name. It doesn't explain relationships between parameters (e.g., provider vs chainId, gas parameters) or clarify the deprecated tokenAddress. The baseline 3 reflects that schema does most documentation work, but the description adds minimal value.

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 ERC1155 setApprovalForAll transaction for signing') and the outcome ('Returns transaction data that can be signed and broadcast'). It distinguishes from sibling tools like 'prepareERC1155Transfer' or 'setNFTApprovalForAll' by specifying the exact ERC1155 approval operation.

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

Usage Guidelines3/5

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

The description implies usage when preparing an ERC1155 approval transaction for signing, but doesn't explicitly state when to use this vs alternatives like 'prepareERC721SetApprovalForAll' or 'setNFTApprovalForAll'. It mentions the return value purpose but lacks context about prerequisites or integration with other tools.

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