> For the complete documentation index, see [llms.txt](https://metamove.gitbook.io/move-agent-kit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://metamove.gitbook.io/move-agent-kit/create-your-own-tools.md).

# 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

```typescript
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:

```typescript
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

1. Extend the `Tool` class from LangChain
2. Define a unique `name` for your tool
3. Provide a clear `description` of its functionality
4. Implement the `_call` method with your logic

#### Testing Your Tool

```typescript
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

1. Fork the repository
2. Create your tool in the `tools` directory
3. Add tests to the `tests` directory
4. Submit 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
