> ## Documentation Index
> Fetch the complete documentation index at: https://thrackle.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy Token Handlers

> Connect your tokens to the App Manager

The Token Handler contract connects a token to the protocol and the Application Manager, providing the ability to configure rules. You must deploy a token handler for each token you want to connect to the protocol.

## Prerequisites

The following steps must already be completed on the target chain:

1. The [Protocol](/guides/protocol/deploy-protocol) has been deployed

2. You have deployed an [Application Manager](/guides/client/deploy-app-manager)

3. You have created at least one [Application Administrator](/v1/permissions/admin-roles) role in the Application Manager

***

<Tabs>
  <Tab title="ERC-20 Token Handler Deployment">
    1. Ensure the [environment variables](/guides/client/environment-variables) are set correctly. The `DEPLOYMENT_OWNER` and `DEPLOYMENT_OWNER_KEY` are used by the deployment script.

    2. Deploy the token handler:

    ```bash
    forge script script/clientScripts/DeployERC20Handler.s.sol --ffi --broadcast --rpc-url $ETH_RPC_URL
    ```

    3. Configure the Handler:

    Before you run the next script your ERC-20 token must be deployed. Update the `APPLICATION_ERC20_ADDRESS` value within your `.env` file with the address of your token. After updating this value, run the `source .env` command. Now you're ready to run the next script.

    ```bash
    forge script script/clientScripts/DeployERC20HandlerPt2.s.sol --ffi --broadcast --rpc-url $ETH_RPC_URL
    ```

    4. Finally, register this token with your App Manager:

    ```bash
    cast send $APPLICATION_APP_MANAGER "registerToken(string,address)" "Your Token Name" 0x_your_token_address  --private-key $APP_ADMIN_PRIVATE_KEY --rpc-url $ETH_RPC_URL
    ```
  </Tab>

  <Tab title="ERC-721 Token Handler Deployment">
    1. Ensure the [environment variables](/guides/client/environment-variables) are set correctly. The `DEPLOYMENT_OWNER` and `DEPLOYMENT_OWNER_KEY` are used by the deployment script.

    2. Deploy the token handler:

    ```bash
    forge script script/clientScripts/DeployERC721Handler.s.sol --ffi --broadcast
    ```

    3. Configure the Handler:

    Before you run the next script your ERC-721 token must be deployed. Update the `APPLICATION_ERC721_ADDRESS_1` value within your `.env` file with the address of your token. After updating this value, run the `source .env` command. Now you're ready to run the next script.

    ```bash
    forge script script/clientScripts/DeployERC721HandlerPt2.s.sol --ffi --broadcast
    ```

    4. Finally, register this token with your App Manager:

    ```bash
    cast send $APPLICATION_APP_MANAGER "registerToken(string,address)" "Your Token Name" 0x_your_token_address  --private-key $APP_ADMIN_PRIVATE_KEY --rpc-url $ETH_RPC_URL
    ```
  </Tab>
</Tabs>
