Skip to main content
Glama
kukapay

bsc-multisend-mcp

distributeNative

Send BNB to multiple BSC addresses in a single transaction using the C98MultiSend contract for bulk transfers.

Instructions

Send BNB to multiple addresses on BSC using the C98MultiSend contract.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • index.js:103-149 (registration)
    Registration of the 'distributeNative' tool using server.tool(), including inline schema and handler function.
    server.tool(
      'distributeNative',
      'Send BNB to multiple addresses on BSC using the C98MultiSend contract.',
      z.object({
        receivers: z.array(z.string().refine((val) => ethers.isAddress(val), {
          message: 'Invalid BSC address'
        })).describe('Array of BSC addresses to receive BNB.'),
        amounts: z.array(z.number().positive('Amount must be positive')).describe('Array of BNB amounts (in BNB, e.g., 0.1) to send to each receiver.')
      }),
      async ({ receivers, amounts }) => {
        try {
          // Validate inputs
          if (receivers.length !== amounts.length) {
            return {
              content: [{ type: 'text', text: 'Receivers and amounts arrays must have the same length' }],
              isError: true
            };
          }
    
          // Convert amounts to wei and calculate total
          const amountsWei = amounts.map(amount => ethers.parseEther(amount.toString()));
          const totalAmountWei = amountsWei.reduce((sum, amount) => sum + BigInt(amount), BigInt(0));
    
          // Prepare and send transaction
          const tx = await contract.transferMulti(receivers, amountsWei, {
            value: totalAmountWei,
            gasLimit: await contract.transferMulti.estimateGas(receivers, amountsWei, { value: totalAmountWei })
          });
    
          // Wait for transaction confirmation
          const receipt = await tx.wait();
    
          return {
            content: [{
              type: 'text',
              text: `BNB distribution successful. Tx Hash: ${receipt.hash}`
            }],
            isError: false
          };
        } catch (error) {
          return {
            content: [{ type: 'text', text: `Error executing BNB distribution: ${error.message}` }],
            isError: true
          };
        }
      }
    );
  • Handler function that validates inputs, converts amounts to wei, calls contract.transferMulti to distribute BNB, and returns success or error response.
    async ({ receivers, amounts }) => {
      try {
        // Validate inputs
        if (receivers.length !== amounts.length) {
          return {
            content: [{ type: 'text', text: 'Receivers and amounts arrays must have the same length' }],
            isError: true
          };
        }
    
        // Convert amounts to wei and calculate total
        const amountsWei = amounts.map(amount => ethers.parseEther(amount.toString()));
        const totalAmountWei = amountsWei.reduce((sum, amount) => sum + BigInt(amount), BigInt(0));
    
        // Prepare and send transaction
        const tx = await contract.transferMulti(receivers, amountsWei, {
          value: totalAmountWei,
          gasLimit: await contract.transferMulti.estimateGas(receivers, amountsWei, { value: totalAmountWei })
        });
    
        // Wait for transaction confirmation
        const receipt = await tx.wait();
    
        return {
          content: [{
            type: 'text',
            text: `BNB distribution successful. Tx Hash: ${receipt.hash}`
          }],
          isError: false
        };
      } catch (error) {
        return {
          content: [{ type: 'text', text: `Error executing BNB distribution: ${error.message}` }],
          isError: true
        };
      }
    }
  • Zod schema defining the input parameters: arrays of receiver addresses and BNB amounts with validation.
    z.object({
      receivers: z.array(z.string().refine((val) => ethers.isAddress(val), {
        message: 'Invalid BSC address'
      })).describe('Array of BSC addresses to receive BNB.'),
      amounts: z.array(z.number().positive('Amount must be positive')).describe('Array of BNB amounts (in BNB, e.g., 0.1) to send to each receiver.')
    }),
Install Server

Other Tools

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/kukapay/bsc-multisend-mcp'

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