Skip to main content
Glama

transfer_erc1155

Transfer ERC1155 tokens between addresses using the EVM MCP Server. Specify token details, recipient address, and network to move fungible or non-fungible tokens securely.

Instructions

Transfer ERC1155 tokens to another address. ERC1155 is a multi-token standard that can represent both fungible and non-fungible tokens in a single contract.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountYesThe quantity of tokens to send (e.g., '1' for a single NFT or '10' for 10 fungible tokens)
networkNoNetwork name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. ERC1155 tokens exist across many networks. Defaults to Ethereum mainnet.
privateKeyYesPrivate key of the token owner account in hex format (with or without 0x prefix). SECURITY: This is used only for transaction signing and is not stored.
toAddressYesThe recipient wallet address that will receive the tokens
tokenAddressYesThe contract address of the ERC1155 token collection (e.g., '0x76BE3b62873462d2142405439777e971754E8E77')
tokenIdYesThe ID of the specific token to transfer (e.g., '1234')

Implementation Reference

  • Main handler function that executes the ERC1155 transfer using safeTransferFrom on the contract, handles ENS resolution for addresses, formats private key, creates wallet client, sends transaction, and returns tx hash, tokenId, and amount.
    export async function transferERC1155( tokenAddressOrEns: string, toAddressOrEns: string, tokenId: bigint, amount: string, privateKey: string | `0x${string}`, network: string = 'ethereum' ): Promise<{ txHash: Hash; tokenId: string; amount: string; }> { // Resolve ENS names to addresses if needed const tokenAddress = (await resolveAddress( tokenAddressOrEns, network )) as Address; const toAddress = (await resolveAddress(toAddressOrEns, network)) as Address; // Ensure the private key has 0x prefix const formattedKey = typeof privateKey === 'string' && !privateKey.startsWith('0x') ? (`0x${privateKey}` as `0x${string}`) : (privateKey as `0x${string}`); // Create wallet client for sending the transaction const walletClient = getWalletClient(formattedKey, network); const fromAddress = walletClient.account!.address; // Parse amount to bigint const amountBigInt = BigInt(amount); // Send the transaction const hash = await walletClient.writeContract({ address: tokenAddress, abi: erc1155TransferAbi, functionName: 'safeTransferFrom', args: [fromAddress, toAddress, tokenId, amountBigInt, '0x'], account: walletClient.account!, chain: walletClient.chain }); return { txHash: hash, tokenId: tokenId.toString(), amount }; }
  • MCP tool registration for 'transfer_erc1155', including name, description, Zod input schema, and inline handler that delegates to services.transferERC1155 after formatting inputs.
    server.tool( 'transfer_erc1155', 'Transfer ERC1155 tokens to another address. ERC1155 is a multi-token standard that can represent both fungible and non-fungible tokens in a single contract.', { privateKey: z .string() .describe( 'Private key of the token owner account in hex format (with or without 0x prefix). SECURITY: This is used only for transaction signing and is not stored.' ), tokenAddress: z .string() .describe( "The contract address of the ERC1155 token collection (e.g., '0x76BE3b62873462d2142405439777e971754E8E77')" ), tokenId: z .string() .describe("The ID of the specific token to transfer (e.g., '1234')"), amount: z .string() .describe( "The quantity of tokens to send (e.g., '1' for a single NFT or '10' for 10 fungible tokens)" ), toAddress: z .string() .describe('The recipient wallet address that will receive the tokens'), network: z .string() .optional() .describe( "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. ERC1155 tokens exist across many networks. Defaults to Ethereum mainnet." ) }, async ({ privateKey, tokenAddress, tokenId, amount, toAddress, network = 'ethereum' }) => { try { // Get the formattedKey with 0x prefix const formattedKey = privateKey.startsWith('0x') ? (privateKey as `0x${string}`) : (`0x${privateKey}` as `0x${string}`); const result = await services.transferERC1155( tokenAddress as Address, toAddress as Address, BigInt(tokenId), amount, formattedKey, network ); return { content: [ { type: 'text', text: JSON.stringify( { success: true, txHash: result.txHash, network, contract: tokenAddress, tokenId: result.tokenId, amount: result.amount, recipient: toAddress }, null, 2 ) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error transferring ERC1155 tokens: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
  • Zod schema for input parameters validation of the transfer_erc1155 tool: privateKey, tokenAddress, tokenId, amount, toAddress, network.
    { privateKey: z .string() .describe( 'Private key of the token owner account in hex format (with or without 0x prefix). SECURITY: This is used only for transaction signing and is not stored.' ), tokenAddress: z .string() .describe( "The contract address of the ERC1155 token collection (e.g., '0x76BE3b62873462d2142405439777e971754E8E77')" ), tokenId: z .string() .describe("The ID of the specific token to transfer (e.g., '1234')"), amount: z .string() .describe( "The quantity of tokens to send (e.g., '1' for a single NFT or '10' for 10 fungible tokens)" ), toAddress: z .string() .describe('The recipient wallet address that will receive the tokens'), network: z .string() .optional() .describe( "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. ERC1155 tokens exist across many networks. Defaults to Ethereum mainnet." ) },
  • ERC1155 ABI fragments used for safeTransferFrom and balanceOf in the transfer function.
    const erc1155TransferAbi = [ { inputs: [ { type: 'address', name: 'from' }, { type: 'address', name: 'to' }, { type: 'uint256', name: 'id' }, { type: 'uint256', name: 'amount' }, { type: 'bytes', name: 'data' } ], name: 'safeTransferFrom', outputs: [], stateMutability: 'nonpayable', type: 'function' }, { inputs: [ { type: 'address', name: 'account' }, { type: 'uint256', name: 'id' } ], name: 'balanceOf', outputs: [{ type: 'uint256' }], stateMutability: 'view', type: 'function' } ] as const;

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/chulanpro5/evm-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server