> 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/getting-started.md).

# Getting Started

## Getting Started

### Prerequisites

Before you begin working with Move Agent Kit, ensure you have the following prerequisites installed:

* Node.js 16.x or higher
* Git

### Installation

#### Using npm

```bash
npm i move-agent-kit
```

#### From Source

```bash
git clone https://github.com/Metamove/move-agent-kit
cd move-agent-kit
npm i
```

### Quick Start Guide

#### 1. Basic Setup

First, import the necessary modules:

```typescript
const aptosConfig = new AptosConfig({
	network: Network.MAINNET,
});

const aptos = new Aptos(aptosConfig);

const account = await aptos.deriveAccountFromPrivateKey({
	privateKey: new Ed25519PrivateKey(
		PrivateKey.formatPrivateKey(
			process.env.PRIVATE_KEY,
			PrivateKeyVariants.Ed25519,
		),
	),
});
```

#### 2. Configure Your Environment

Create a configuration file `.env` in your project root:

```env
APTOS_PRIVATE_KEY="private key"
ANTHROPIC_API_KEY="API Key"
OPENAI_API_KEY="API Key"
```

#### 3. Initialize the Client

```typescript
const signer = new LocalSigner(account, Network.MAINNET);
const agent = new AgentRuntime(signer, aptos, {
	PANORA_API_KEY: process.env.PANORA_API_KEY, // optional
	OPENAI_API_KEY: process.env.OPENAI_API_KEY // optional
});
const tools = createAptosTools(aptosAgent);
```

#### 4. Basic Operations Examples

**Token Transfer**

```python
const result = agent.transferTokens("to_address", 1.0)
```

**Read Blockchain Data**

```typescript
// Get Balance
const balance = agent.getBalance("0x123...")

// Get transaction details
const tx_info = agent.transferTokens("0x789...")
```

### Working with Langchain

```typescript
import { ChatAnthropic } from "@langchain/anthropic";
import { MemorySaver } from "@langchain/langgraph";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { HumanMessage } from "@langchain/core/messages";

const llm = new ChatAnthropic({
    temperature: 0.7,
    model: "claude-3-5-sonnet-20241022",
});

const memory = new MemorySaver();

const agent = createReactAgent({
    llm,
    tools,
    checkpointSaver: memory,
    messageModifier: `
        You are a helpful agent that can interact onchain using the Aptos Agent Kit. You are
        empowered to interact onchain using your tools. If you ever need funds, you can request them from the
        faucet. If not, you can provide your wallet details and request funds from the user. If there is a 5XX
        (internal) HTTP error code, ask the user to try again later. If someone asks you to do something you
        can't do with your currently available tools, you must say so, and encourage them to implement it
        themselves using the Aptos Agent Kit, recommend they go to https://metamove.build/move-agent-kit for more information. Be
        concise and helpful with your responses. Refrain from restating your tools' descriptions unless it is explicitly requested.
    `,
});

const stream = await agent.stream(
    {
        messages: [new HumanMessage("Deposit 10 APT on Joule")],
    },
    config
);

for await (const chunk of stream) {
    if ("agent" in chunk) {
        console.log(chunk.agent.messages[0].content);
    } else if ("tools" in chunk) {
        console.log(chunk.tools.messages[0].content);
    }
    console.log("-------------------");
}
```

### Next Steps

* Explore the Core Components documentation for detailed information about each module
* Check out the Examples section for more complex usage scenarios
* Review the Security Considerations for best practices when using the kit

### Troubleshooting Common Issues

#### Connection Issues

If you're experiencing connection issues:

1. Verify your node URL is correct and accessible
2. Check your network connectivity
3. Ensure your node is synced

#### Transaction Failures

Common causes of transaction failures:

1. Insufficient gas
2. Invalid account permissions
3. Network congestion

For more detailed troubleshooting, refer to the Troubleshooting section.
