> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-zh.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# Goat 集成

> 使用 LangChain Python 与 Goat 工具集成。

[GOAT](https://github.com/goat-sdk/goat) 是专为 AI 代理设计的金融工具包。

## 概述

创建能够执行以下操作的代理：

* 发送和接收付款
* 购买实体和数字商品及服务
* 参与各种投资策略：
  * 赚取收益
  * 在预测市场下注
* 购买加密资产
* 将任何资产代币化
* 获取财务洞察

### 工作原理

GOAT 利用区块链、加密货币（如稳定币）和钱包作为基础设施，使代理成为经济参与者：

1. 为您的代理分配一个 [钱包](https://github.com/goat-sdk/goat/tree/main#chains-and-wallets)
2. 允许它在 [任何地方](https://github.com/goat-sdk/goat/tree/main#chains-and-wallets) 进行交易
3. 使用超过 [200 个工具](https://github.com/goat-sdk/goat/tree/main#tools)

查看 [GOAT 支持的所有内容](https://github.com/goat-sdk/goat/tree/main#chains-and-wallets)。

**轻量且可扩展**
与其他工具包不同，GOAT 旨在保持核心精简，仅安装您需要的工具，从而实现轻量级和可扩展性。

如果您在我们超过 200 个集成中未找到所需内容，您可以轻松：

* 创建您自己的插件
* 集成新链
* 集成新钱包
* 集成新的代理框架

查看 [如何贡献](https://github.com/goat-sdk/goat/tree/main#-contributing)。

### 快速入门

最好的开始方式是使用下面的快速入门指南。查看如何配置 GOAT 以实现以下任何用例。

* **按用例**
  * **资金传输**
    * 发送和接收付款 \[[EVM](https://github.com/goat-sdk/goat/tree/main/python/examples/by-use-case/evm-send-and-receive-tokens), [Solana](https://github.com/goat-sdk/goat/tree/main/python/examples/by-use-case/solana-send-and-receive-tokens)]
  * **投资**
    * 生成收益 \[[Solana](https://github.com/goat-sdk/goat/tree/main/python/examples/by-use-case/solana-usdc-yield-deposit)]
    * 购买加密资产 \[[EVM](https://github.com/goat-sdk/goat/tree/main/python/examples/by-use-case/evm-swap-tokens), [Solana](https://github.com/goat-sdk/goat/tree/main/python/examples/by-use-case/solana-swap-tokens)]
* **按钱包**
  * [Crossmint](https://github.com/goat-sdk/goat/tree/main/python/examples/by-wallet/crossmint)
* **查看 [所有 Python 快速入门](https://github.com/goat-sdk/goat/tree/main/python/examples)**。

## 设置

1. 安装核心包和 langchain 适配器：

```bash theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
pip install goat-sdk goat-sdk-adapter-langchain
```

2. 安装您想使用的钱包类型（例如 solana）：

```bash theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
pip install goat-sdk-wallet-solana
```

3. 安装您想在该链上使用的插件：

```bash theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
pip install goat-sdk-plugin-spl-token
```

## 实例化

现在我们可以实例化工具包：

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from goat_adapters.langchain import get_on_chain_tools
from goat_wallets.solana import solana, send_solana
from goat_plugins.spl_token import spl_token, SplTokenPluginOptions
from goat_plugins.spl_token.tokens import SPL_TOKENS

# Initialize Solana client
client = SolanaClient(os.getenv("SOLANA_RPC_ENDPOINT"))

# Initialize regular Solana wallet
keypair = Keypair.from_base58_string(os.getenv("SOLANA_WALLET_SEED") or "")
wallet = solana(client, keypair)

tools = get_on_chain_tools(
        wallet=wallet,
        plugins=[
            send_solana(),
            spl_token(SplTokenPluginOptions(
                network="mainnet",  # Using devnet as specified in .env
                tokens=SPL_TOKENS
            )),
        ],
    )
```

## 调用

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
tools["get_balance"].invoke({ "address": "0x1234567890123456789012345678901234567890" })
```

## 在代理中使用

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import os
import asyncio
from dotenv import load_dotenv

# Load environment variables
load_dotenv()

from solana.rpc.api import Client as SolanaClient
from solders.keypair import Keypair

from goat_adapters.langchain import get_on_chain_tools
from goat_wallets.solana import solana, send_solana
from goat_plugins.spl_token import spl_token, SplTokenPluginOptions
from goat_plugins.spl_token.tokens import SPL_TOKENS

# Initialize Solana client
client = SolanaClient(os.getenv("SOLANA_RPC_ENDPOINT"))

# Initialize regular Solana wallet
keypair = Keypair.from_base58_string(os.getenv("SOLANA_WALLET_SEED") or "")
wallet = solana(client, keypair)

# Initialize LLM
llm = ChatOpenAI(model="gpt-4.1-mini")

def main():
    # Initialize tools with Solana wallet
    tools = get_on_chain_tools(
        wallet=wallet,
        plugins=[
            send_solana(),
            spl_token(SplTokenPluginOptions(
                network="mainnet",  # Using devnet as specified in .env
                tokens=SPL_TOKENS
            )),
        ],
    )

    # Initialize agent
    # Your agent code here


if __name__ == "__main__":
    main()
```

***

## API 参考

* 如需完整工具列表，请参阅 [GOAT SDK 文档](https://github.com/goat-sdk/goat)。

***

<div className="source-links">
  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/i18n\zh-CN\oss\python\integrations\tools\goat.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>

  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>
</div>
