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

# Develop Custom Proxy

> Guide how to develop a TAC Proxy

## Documentation

The contents of the *Custom Proxy* page block you are viewing are primarily for informational purposes.
For complete details on Custom Proxy development, please refer to the official documentation linked below:

> [card] [Custom Proxy](https://www.npmjs.com/package/@tonappchain/evm-ccl)
>
> Developer documentation within `@tonappchain/evm-ccl` NPM-package

You can also reach out to our developer community in [Telegram](https://t.me/TACbuild).

## Installation

Setting up TAC Proxy development requires installing the TAC cross-chain libraries and configuring your Solidity development environment.

TAC Proxy development currently requires Hardhat. Foundry support is planned in future.

```bash npm theme={null}
npm install --save @tonappchain/evm-ccl@latest
```

```bash yarn theme={null}
yarn add @tonappchain/evm-ccl@latest
```

```bash pnpm theme={null}
pnpm add @tonappchain/evm-ccl@latest
```

## Hardhat Environment Setup

Ensure your Hardhat project includes the necessary dependencies:

```json package.json theme={null}
{
  "devDependencies": {
    "@nomicfoundation/hardhat-toolbox": "^5.0.0",
    "hardhat": "^2.22.5",
    "ethers": "^6.13.2",
    "chai": "^4.3.7",
    "ts-node": "^10.9.2",
    "typescript": "^5.6.3",
    "@tonappchain/evm-ccl": "^latest"
  }
}
```

Configure your `hardhat.config.js` for TAC networks:

```javascript hardhat.config.js theme={null}
require("@nomicfoundation/hardhat-toolbox");

module.exports = {
  solidity: {
    version: "0.8.28",
    settings: {
      optimizer: {
        enabled: true,
        runs: 200,
      },
    },
  },
  networks: {
    tac_testnet: {
      url: "https://rpc-public-spb.tac.build",
      chainId: 2391,
      accounts: [process.env.PRIVATE_KEY || ""],
      gasPrice: 20000000000,
    },
    tac_mainnet: {
      url: "https://rpc-public.tac.build",
      chainId: 239,
      accounts: [process.env.PRIVATE_KEY || ""],
      gasPrice: 20000000000,
    },
  },
};
```

## Project Structure Setup

Create an organized project structure for proxy development:

**1. Create Contract Directory**

Organize your contracts with clear separation between proxy and application logic:

```
contracts/
├── proxies/          # TAC proxy contracts
│   ├── MyProxy.sol
│   └── MyNFTProxy.sol
├── interfaces/       # Custom interfaces
│   └── IMyDApp.sol
├── libraries/        # Utility libraries
└── mocks/           # Testing contracts
    ├── TestToken.sol
    └── TestNFT.sol
```

**2. Setup Testing Environment**

Create a test directory with proper organization:

```
test/
├── proxies/          # Proxy-specific tests
│   ├── MyProxy.test.ts
│   └── NFTProxy.test.ts
├── integration/      # Cross-chain integration tests
└── helpers/         # Test utilities
    └── tacTestHelpers.ts
```

**3. Configure Environment Variables**

Create a `.env` file for sensitive configuration:

```bash .env theme={null}
# Deployment
PRIVATE_KEY=your_private_key_here

# Network Configuration
TAC_TESTNET_RPC=https://rpc-public-spb.tac.build
TAC_MAINNET_RPC=https://rpc-public.tac.build

# Optional: API Keys
ETHERSCAN_API_KEY=your_etherscan_api_key
```

> [!WARNING]
>
> Never commit your `.env` file. Add it to your `.gitignore` immediately.

## Verify Installation

Create a basic proxy contract to verify your setup:

```solidity contracts/TestProxy.sol theme={null}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import { TacProxyV1 } from "@tonappchain/evm-ccl/contracts/proxies/TacProxyV1.sol";
import { TacHeaderV1 } from "@tonappchain/evm-ccl/contracts/core/Structs.sol";

contract TestProxy is TacProxyV1 {
    event MessageReceived(address indexed caller, string message);
    
    constructor(address crossChainLayer) TacProxyV1(crossChainLayer) {}
    
    function receiveMessage(bytes calldata tacHeader, bytes calldata arguments)
        external
        _onlyCrossChainLayer
    {
        TacHeaderV1 memory header = _decodeTacHeader(tacHeader);
        string memory message = abi.decode(arguments, (string));
        
        emit MessageReceived(header.tvmCaller, message);
    }
}
```

Compile to verify setup:

```bash theme={null}
npx hardhat compile
```

> [!TIP]
>
> If compilation succeeds, your environment is properly configured for TAC Proxy development.

## Common Setup Issues

> [accordion] Compilation Errors
>
> **Problem**: Import resolution failures or compilation errors
>
> **Solutions**:
>
> * Ensure `@tonappchain/evm-ccl` is properly installed
> * Verify Solidity version compatibility (0.8.28+)
> * Check import paths are correct
> * Reset and reinstall dependencies:
>   ```bash theme={null}
>   rm -rf node_modules package-lock.json
>   npm install
>   ```
> * Clean and rebuild:
>   ```bash theme={null}
>   npx hardhat clean && npx hardhat compile
>   ```

> [accordion] Network Connection Issues
>
> **Problem**: Unable to connect to TAC network
>
> **Solutions**:
>
> * Verify RPC URLs are correct
> * Check network configuration in hardhat.config.js
> * Test connection manually: `curl https://rpc-public-spb.tac.build`
> * Ensure firewall allows outbound connections
>
> ```javascript theme={null}
> // Test network connectivity
> const { ethers } = require("hardhat");
> async function testConnection() {
>   const provider = new ethers.JsonRpcProvider("https://rpc-public-spb.tac.build");
>   const blockNumber = await provider.getBlockNumber();
>   console.log("Connected! Latest block:", blockNumber);
> }
> ```

> [accordion] Private Key Issues
>
> **Problem**: Deployment fails with account/key errors
>
> **Solutions**:
>
> * Verify private key is in `.env` file
> * Ensure private key starts with `0x` if required by your configuration
> * Check that the account has sufficient TAC tokens for deployment. Get them [here](ecosystem/faucet)

## What's Next?

Environment ready? Let's get to examples:

> [card] [Basic Proxy Example](https://docs.tac.build/proxies/custom-proxy/basic-proxy.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.