Skip to main content
Glama

prepareERC721Transfer

Prepare ERC721 NFT transfer transactions for signing by generating transaction data with required parameters like contract address, token ID, and recipient address.

Instructions

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

Input Schema

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

Implementation Reference

  • Registration of the 'prepareERC721Transfer' MCP tool, including input schema, description, and handler function. The handler prepares unsigned transaction data by calling ethersService.prepareERC721Transfer and formats the response with NFT info and tx details.
    server.tool( "prepareERC721Transfer", "Prepare an ERC721 NFT transfer transaction for signing. Returns transaction data that can be signed and broadcast.", { contractAddress: contractAddressSchema, tokenId: tokenIdSchema, toAddress: 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.prepareERC721Transfer( params.contractAddress, params.toAddress, params.tokenId, params.fromAddress, params.provider, params.chainId, options ); return { content: [{ type: "text", text: `ERC721 Transfer Transaction Prepared: Collection: ${nftInfo.name} (${nftInfo.symbol}) Token ID: ${params.tokenId} From: ${params.fromAddress} To: ${params.toAddress} 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 transfer transaction: ${error instanceof Error ? error.message : String(error)}` }] }; } } );
  • The core handler function that implements the tool logic: fetches collection info, prepares gas options, calls the underlying ethersService to generate unsigned tx, and returns formatted JSON transaction data.
    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.prepareERC721Transfer( params.contractAddress, params.toAddress, params.tokenId, params.fromAddress, params.provider, params.chainId, options ); return { content: [{ type: "text", text: `ERC721 Transfer Transaction Prepared: Collection: ${nftInfo.name} (${nftInfo.symbol}) Token ID: ${params.tokenId} From: ${params.fromAddress} To: ${params.toAddress} 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 transfer transaction: ${error instanceof Error ? error.message : String(error)}` }] }; } }
  • Input schema (Zod) for the prepareERC721Transfer tool, defining parameters like contract address, token ID, addresses, chain, provider, and optional gas parameters.
    { contractAddress: contractAddressSchema, tokenId: tokenIdSchema, toAddress: addressSchema, fromAddress: addressSchema, provider: providerSchema, chainId: chainIdSchema, gasLimit: z.string().optional(), gasPrice: z.string().optional(), maxFeePerGas: z.string().optional(), maxPriorityFeePerGas: z.string().optional()

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