Skip to main content
Glama

sui-transfer

Transfer SUI tokens (in mist) to one or multiple wallet addresses on Sui blockchain networks, including mainnet, testnet, devnet, and localnet.

Instructions

transfer SUI(in mist) to single or multiple addresses

Input Schema

NameRequiredDescriptionDefault
amountsYes
networkNomainnet
recipientsYes

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "amounts": { "items": { "type": "number" }, "minItems": 1, "type": "array" }, "network": { "default": "mainnet", "enum": [ "mainnet", "testnet", "devnet", "localnet" ], "type": "string" }, "recipients": { "items": { "type": "string" }, "minItems": 1, "type": "array" } }, "required": [ "amounts", "recipients" ], "type": "object" }

Implementation Reference

  • The main execution handler for the 'sui-transfer' tool. Processes input parameters, retrieves sender keypair, creates SuiClient, calls batchTransferSUI helper, and returns success/failure response with transaction digest.
    async cb(args: TransferParams) { const network = args.network as SuiNetwork; const amounts = args.amounts.map((amount: number) => BigInt(amount)); const recipients = args.recipients; if (!config.sui.privateKey) throw new Error('Missing private key, please set it in config'); const sender = getKeypairFromPrivateKey(config.sui.privateKey) as Keypair; if (!sender) throw new Error('Invalid private key, please check your config'); const suiClient = new SuiClient({ url: getFullnodeUrl(network) }); let digest = ''; let errMsg = ''; try { digest = await batchTransferSUI(amounts, recipients, sender, suiClient); } catch (error) { errMsg = error as string; } return this.createTextResponse( `Transfer ${digest ? 'successful' : 'failed'}: digest: '${digest}', error: '${errMsg}'` ); }
  • Zod input schema for the tool parameters (network, amounts in mist as numbers, recipient addresses) and its assignment to the tool's paramsSchema.
    const transferParamsSchema = z.object({ network: z.enum(SUI_NETWORKS).default('mainnet'), amounts: z.array(z.number()).nonempty(), recipients: z.array(z.string()).nonempty(), }); type TransferParams = z.output<typeof transferParamsSchema>; export class SuiTransferTool extends BaseTool<TransferParams> { name = 'sui-transfer'; description = 'transfer SUI(in mist) to single or multiple addresses'; paramsSchema = transferParamsSchema;
  • Central registration file that imports the suiTransferTool instance from transfer.ts and includes it in the exported array of all MCP tools.
    import faucetTool from './sui/get-faucet.js'; import suiBalanceTool from './sui/get-balance.js'; import suiTransferTool from './sui/transfer.js'; import randomSuiAccountTool from './account/gen-random.js'; import genMnemonicTool from './account/gen-mnemonic.js'; import genSuiAccountsByMnemonicTool from './account/gen-by-mnemonic.js'; import getAccountInfoByPriKeyTool from './account/get-info-by-pri-key.js'; export default [ faucetTool, suiBalanceTool, suiTransferTool, randomSuiAccountTool, genMnemonicTool, genSuiAccountsByMnemonicTool, getAccountInfoByPriKeyTool, ];
  • Core helper utility function that implements batch SUI transfers: validates inputs, checks balance, builds programmable transaction block to split and transfer coins, signs, executes, and confirms the transaction.
    export async function batchTransferSUI( amounts: bigint[], recipients: string[], sender: Keypair, client: SuiClient ): Promise<string> { if (amounts.length !== recipients.length) throw new Error('Amounts and recipients must have the same length'); // Amount must be greater than 0 if (amounts.some(amount => amount <= BigInt(0))) throw new Error('Amount must be greater than 0'); // Invalid recipient address if (recipients.some(recipient => !isValidSuiAddress(recipient))) { throw new Error('Invalid recipient address'); } const sumAmountsInMist = amounts.reduce((acc, amount) => acc + amount, 0n); const senderAddress = sender.toSuiAddress(); const senderBalance = await getBalanceInMist(senderAddress, client); if (senderBalance === null) throw new Error('Failed to get balance'); if (senderBalance <= sumAmountsInMist) throw new Error(`Insufficient balance: ${senderAddress}, balance: ${senderBalance}`); // Create new transaction const tx = new Transaction(); // Split coins from gas coin const splitCoins = tx.splitCoins(tx.gas, amounts); // Transfer each split coin to corresponding recipient recipients.forEach((recipient, i) => { tx.transferObjects([splitCoins[i]], recipient); }); // Set transaction sender tx.setSender(senderAddress); // Sign and execute transaction const { digest } = await client.signAndExecuteTransaction({ transaction: tx, signer: sender, requestType: 'WaitForLocalExecution', }); // Wait for transaction to be confirmed await client.waitForTransaction({ digest: digest, }); return digest; }

Other Tools

Related 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/0xdwong/sui-mcp'

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