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
| Name | Required | Description | Default |
|---|---|---|---|
| contractAddress | Yes | ||
| operator | Yes | ||
| approved | Yes | ||
| fromAddress | Yes | ||
| provider | No | ||
| chainId | No | ||
| gasLimit | No | ||
| gasPrice | No | ||
| maxFeePerGas | No | ||
| maxPriorityFeePerGas | No |
Implementation Reference
- src/tools/erc721.ts:633-693 (handler)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)}` }] }; } }
- src/tools/erc721.ts:618-694 (registration)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)}` }] }; } } );
- src/tools/erc721.ts:621-632 (schema)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) => {