> For the complete documentation index, see [llms.txt](https://docs.agentipy.fun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.agentipy.fun/tools/transfer-tokens.md).

# Transfer Tokens

The `Transfer Tokens` tool, part of AgentiPy, allows users to send SOL (native Solana) or SPL (Solana Program Library) tokens from the agent's wallet to a specified recipient address on the Solana blockchain.

## Functionality

This tool is implemented in the `TokenTransferManager` class.

### Key Methods:

* `transfer(agent: SolanaAgentKit, to: str, amount: float, mint: str = None) -> str`:
  * Takes a `SolanaAgentKit` instance, the recipient's public key as a string (`to`), the `amount` to transfer (in UI units, e.g., SOL amount or number of SPL tokens), and an optional `mint` address (string) for SPL tokens.
  * If `mint` is `None`, it performs a native SOL transfer. The `amount` is converted to lamports.
  * If `mint` is provided, it performs an SPL token transfer.
    * It determines the Associated Token Account (ATA) for both the sender (agent's wallet) and the recipient for the given `mint`.
    * It fetches the SPL token's mint information to get the `decimals` for correct amount conversion.
    * It constructs an SPL token transfer instruction.
  * The transaction is signed with the agent's wallet.
  * The raw transaction is sent to the network.
  * Returns the transaction signature as a string.

##

**Note:** This tool performs on-chain transactions that will move SOL or SPL tokens from the agent's wallet. Always double-check the recipient address, amount, and network (Devnet/Mainnet) before executing transfers. For SPL token transfers, the sender must have a sufficient balance of the token, and the recipient must have an Associated Token Account (ATA) for that token (though some transfer functions might implicitly create it if needed, this tool's `transfer_checked` implies the ATA should exist or be creatable by the sender if they are also the payer).

## Source Code

You can find the source code for this tool on GitHub: <https://github.com/niceberginc/agentipy/blob/main/agentipy/tools/transfer.py>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.agentipy.fun/tools/transfer-tokens.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
