Create your own tools
Contributor Guide
Building Tools for Move Agent Kit
Move Agent Kit uses LangChain's tool format for all blockchain interactions. This guide will help you create new tools for the kit.
Tool Structure
import { Tool } from "langchain/tools";
class MyMoveTool extends Tool {
name = "my_move_tool";
description = "Description of what your tool does";
constructor() {
super();
}
async _call(args: string): Promise<string> {
// Your tool implementation
}
}
Quick Start Example
Here's a simple token transfer tool example:
import { Tool } from "langchain/tools";
import { AgentRuntime, parseJson } from "../..";
class TokenTransferTool extends Tool {
name = "aptos_transfer_token";
description = `"
this tool can be used to transfer APT, any token or fungible asset to a recipient
if you want to transfer APT, mint will be "0x1::aptos_coin::AptosCoin"
if you want to transfer token other than APT, you need to provide the mint of that specific token
if you want to transfer fungible asset, add fungible asset address as mint
keep to blank if user themselves wants to receive the token and not send to anybody else
Inputs ( input is a JSON string ):
to: string, eg "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa" (optional)
amount: number, eg 1 or 0.01 (required)
mint: string, eg "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT"
or "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa" (required)"`;
constructor(private agent: AgentRuntime) {
super();
}
async _call(args: string): Promise<string> {
const parsedInput = parseJson(input);
// Implement token transfer logic
return JSON.stringify({"data": "Transfer Completed"});
}
}
Tool Requirements
Extend the
Tool
class from LangChainDefine a unique
name
for your toolProvide a clear
description
of its functionalityImplement the
_call
method with your logic
Testing Your Tool
import { test, expect } from '@jest/globals';
test('token transfer tool', async () => {
const tool = new TokenTransferTool();
const result = await tool.call(JSON.stringify({
to: "0x123...",
amount: 100,
mint: "0x456..."
}));
expect(result).toBe(JSON.stringify({"data": "Transfer Completed"}));
});
Contributing Your Tool
Fork the repository
Create your tool in the
tools
directoryAdd tests to the
tests
directorySubmit a pull request to https://github.com/MetaMove/move-agent-kit/pulls
For examples and existing tools, check our GitHub repository: github.com/move-agent-kit/tools
You can even create your own SDK for your tools and use it with createAptosTools
Community Guidelines
Follow TypeScript best practices
Include comprehensive tests
Document your code
Keep tools focused and single-purpose
Need help? Join our Discord: discord.gg/move-agent-kit
Last updated