Skip to main content
Glama

prepareERC1155BatchTransfer

Prepare multiple ERC1155 token transfers in a single transaction for signing and broadcasting on Ethereum networks.

Instructions

Prepare an ERC1155 batch transfer 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
fromAddressYesThe address sending the tokens
toAddressYesThe address receiving the tokens
tokenIdsYesArray of token IDs to transfer
amountsYesArray of amounts to transfer
dataNoAdditional data (default: '0x')
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 MCP tool handler that processes parameters, prepares gas options, delegates to ethersService.prepareERC1155BatchTransfer, formats and returns the unsigned transaction details.
    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.prepareERC1155BatchTransfer( contractAddr, mapped.fromAddress, mapped.toAddress, params.tokenIds, params.amounts, params.data || '0x', mapped.provider, mapped.chainId, options ); return { content: [{ type: "text", text: `ERC1155 Batch Transfer Transaction Prepared: Contract: ${contractAddr} Token IDs: ${params.tokenIds.join(', ')} From: ${mapped.fromAddress} To: ${mapped.toAddress} Amounts: ${params.amounts.join(', ')} 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 batch transfer transaction: ${error instanceof Error ? error.message : String(error)}` }] }; } }
  • Zod input schema validating contract details, addresses, token IDs and amounts arrays, optional data, provider/chain, and gas parameters.
    { contractAddress: contractAddressSchema, tokenAddress: tokenAddressSchema.optional(), // Deprecated fromAddress: addressSchema.describe("The address sending the tokens"), toAddress: addressSchema.describe("The address receiving the tokens"), tokenIds: z.array(tokenIdSchema).describe("Array of token IDs to transfer"), amounts: z.array(z.string()).describe("Array of amounts to transfer"), data: z.string().optional().describe("Additional data (default: '0x')"), provider: providerSchema, chainId: chainIdSchema, gasLimit: z.string().optional(), gasPrice: z.string().optional(), maxFeePerGas: z.string().optional(), maxPriorityFeePerGas: z.string().optional() },
  • MCP server tool registration call that associates the tool name, description, input schema, and handler function.
    server.tool( "prepareERC1155BatchTransfer", "Prepare an ERC1155 batch transfer transaction for signing. Returns transaction data that can be signed and broadcast.", { contractAddress: contractAddressSchema, tokenAddress: tokenAddressSchema.optional(), // Deprecated fromAddress: addressSchema.describe("The address sending the tokens"), toAddress: addressSchema.describe("The address receiving the tokens"), tokenIds: z.array(tokenIdSchema).describe("Array of token IDs to transfer"), amounts: z.array(z.string()).describe("Array of amounts to transfer"), data: z.string().optional().describe("Additional data (default: '0x')"), 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.prepareERC1155BatchTransfer( contractAddr, mapped.fromAddress, mapped.toAddress, params.tokenIds, params.amounts, params.data || '0x', mapped.provider, mapped.chainId, options ); return { content: [{ type: "text", text: `ERC1155 Batch Transfer Transaction Prepared: Contract: ${contractAddr} Token IDs: ${params.tokenIds.join(', ')} From: ${mapped.fromAddress} To: ${mapped.toAddress} Amounts: ${params.amounts.join(', ')} 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 batch transfer transaction: ${error instanceof Error ? error.message : String(error)}` }] }; } } );

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