Smart Contract Cross-chain

Although TRON has implemented cross-chain transfer based on TRC-10 tokens, this token-based cross-chain mechanism has certain limitations. As TVM provides developers with a flexible, safe, and programmable environment to use Solidity to develop smart contracts, the cross-chain invocation of smart contracts will bring more possibilities to TRON's cross-chain ecology. Therefore, smart contract cross-chain has also become an indispensable part of TRON's cross-chain ecology.

Compared with the cross-chain of TRC-10, the cross-chain complexity of smart contracts is higher. See the following example:

Tom on TRON wants to transfer 100 USDT to Jerry on the parachain, to complete this transaction, some conditions must be met:

For Tether, the deployer of the smart contract:

  • Deploying USDT contracts on TRON and the parachain at the same time;

  • Design contract methods dedicated to cross-chain transfer;

For Tom and Jerry:

  • Possess sufficient Solidity knowledge to confirm whether the contract method logic is consistent with their expectations

For the maintainers of parachains:

  • Ensure that the proxy account is activated and has a certain balance to pay the transaction fee

When the conditions are met, Tom only needs to call the cross-chain transfer method on the TRON main chain, and Jerry can receive the corresponding tokens.

In the above example, some conditions are mentioned, which can be summarized as:

  1. Cross-chain contracts must be deployed on both the source chain and the target chain

  2. Contract methods that support cross-chain calls must exist on both chains at the same time, and the method names and parameters must be exactly the same

  3. When writing a contract method, the developer needs to add two parameters to the method: fromContractAddr (the contract address of the source chain) and toContractAddr (the contract address of the target chain)

  4. After receiving the cross-chain contract transaction, the target chain will set the owner of the contract transaction to be executed as the proxy address. At the same time, the cross-chain contract method needs to determine whether the owner address is a proxy address to prevent malicious calls from illegal users

  5. The Proxy account should be activated on the parachain, and a certain amount of balance should be reserved to pay the energy fee