Skip to main content
Glama

prepareERC1155Transfer

Prepare ERC1155 token transfer transactions for signing by generating transaction data with required parameters like contract addresses, token IDs, and amounts.

Instructions

Prepare an ERC1155 token 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
tokenIdYesThe ID of the token to query
amountYesThe amount of tokens 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

  • Registration of the 'prepareERC1155Transfer' MCP tool, including schema, description, and inline handler function.
    server.tool( "prepareERC1155Transfer", "Prepare an ERC1155 token 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"), tokenId: tokenIdSchema, amount: z.string().describe("The amount of tokens 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.prepareERC1155Transfer( contractAddr, mapped.fromAddress, mapped.toAddress, mapped.tokenId, mapped.amount, params.data || '0x', mapped.provider, mapped.chainId, options ); return { content: [{ type: "text", text: `ERC1155 Transfer Transaction Prepared: Contract: ${contractAddr} Token ID: ${mapped.tokenId} From: ${mapped.fromAddress} To: ${mapped.toAddress} Amount: ${mapped.amount} 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 transfer transaction: ${error instanceof Error ? error.message : String(error)}` }] }; } } );
  • The handler function that executes the tool logic: maps input parameters, prepares gas options, calls ethersService.prepareERC1155Transfer to get unsigned tx data, and returns formatted 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.prepareERC1155Transfer( contractAddr, mapped.fromAddress, mapped.toAddress, mapped.tokenId, mapped.amount, params.data || '0x', mapped.provider, mapped.chainId, options ); return { content: [{ type: "text", text: `ERC1155 Transfer Transaction Prepared: Contract: ${contractAddr} Token ID: ${mapped.tokenId} From: ${mapped.fromAddress} To: ${mapped.toAddress} Amount: ${mapped.amount} 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 transfer transaction: ${error instanceof Error ? error.message : String(error)}` }] }; } }
  • Zod schema for input parameters of the prepareERC1155Transfer tool, including contract details, addresses, token info, gas options, and deprecated tokenAddress field.
    contractAddress: contractAddressSchema, tokenAddress: tokenAddressSchema.optional(), // Deprecated fromAddress: addressSchema.describe("The address sending the tokens"), toAddress: addressSchema.describe("The address receiving the tokens"), tokenId: tokenIdSchema, amount: z.string().describe("The amount of tokens 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() },

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