Skip to main content
Proxy functions are the heart of your TAC contracts - they receive cross-chain calls from TON users and execute your application logic. This guide covers how to implement robust proxy functions that handle different use cases and error conditions.

Function Signature Requirements

Every proxy function that handles cross-chain calls must follow this exact pattern:
The function above also can be payable. You can name the function as you wish (e.g. myProxyFunction, invokeWithCallback, swap, etc.), but it must accept two bytes arguments:
Required Components:
  • bytes calldata tacHeader - Contains verified TON user information
  • bytes calldata arguments - Your custom encoded parameters
  • external visibility - Functions must be externally callable
  • _onlyCrossChainLayer modifier - Security requirement
Important: Only the Cross-Chain Layer (CCL) contract can call these functions. When a user on TON sends a message, the CCL automatically transfers any bridged tokens to your proxy contract before calling your function.

Parameter Encoding and Decoding

Simple Parameters

For basic data types, use straightforward encoding:

Complex Parameters

For complex data with arrays or nested structures:

Complete Implementation Walkthrough

Let’s build a complete proxy function step-by-step, showing external dApp integration - the most common real-world pattern implementing TON->TAC->TON transaction type:
This example shows the complete flow:
  • External Dapp contract integration (lines 11-13, 19-21, 32-38)
  • Token approval for external contracts (line 33)
  • Processing and getting results (lines 35-38)
  • RoundTrip response pattern (lines 48-58)
  • Proper fee handling for RoundTrip messages (lines 52-53)
Important Notes:
  • Use _sendMessageV1 for ERC20 token bridging only
  • The CCL automatically handles token transfers to your proxy before calling your function
  • Always include the NFTAmount import when using OutMessageV1

What’s Next?

Now that you understand how to implement proxy functions, learn about managing fees:

Fee Management

Understand how to handle protocol fees and executor payments