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) => {

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