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

# TRON Contracts

> This guide explains how to interact with the rhino.fi Bridge contract on Tron.

## ABI

<AccordionGroup>
  <Accordion title="ABI">
    ```json abi.js theme={null}
    [
      {
        inputs: [
          {
            internalType: "address",
            name: "token",
            type: "address",
          },
          {
            internalType: "uint256",
            name: "amount",
            type: "uint256",
          },
          {
            internalType: "uint256",
            name: "commitmentId",
            type: "uint256",
          },
        ],
        name: "depositWithId",
        outputs: [],
        stateMutability: "nonpayable",
        type: "function",
      },
      {
        inputs: [],
        name: "depositNative",
        outputs: [],
        stateMutability: "payable",
        type: "function",
      },
    ];
    ```
  </Accordion>
</AccordionGroup>

### Setup

For this example we'll use `tronweb` to interact with the contract, but you can replace it with any Tron library of your choice.

Make sure to install it first:

<CodeGroup>
  ```bash yarn theme={null}
  yarn add tronweb
  ```

  ```bash npm theme={null}
  npm install tronweb
  ```
</CodeGroup>

## Interacting with the Contract

To execute a bridge transaction, call the `depositWithId` (TRC20) function as follows:

<Info>
  The `commitmentId` required by the contract corresponds to the `quoteId` returned by the API.

  To obtain the `commitmentId`, first request a quote from the API, then commit it. The response will include the `quoteId`, which should be used as the `commitmentId` in the contract call.

  See [the API bridge example](/api-integration/bridge#6-full-example) for details.
</Info>

<CodeGroup>
  ```javascript tronweb theme={null}
  import { TronWeb, providers } from 'tronweb'
  import getBridgeConfigs from './getBridgeConfigs'
  // You can find the bridgeABI above in the ABI section
  import bridgeAbi from './bridgeAbi'

  export const callTronBridgeContract = async (
    {
      token,
      amount,
      commitmentId,
      tronWalletAddress
    }) => {
    // See API Integration -> Fetch Bridge Configs for the full implementation
    const configs = await getBridgeConfigs()
    const chainConfig = configs[chain]

    // Replace with your wallet implementation
    const tronWeb = new TronWeb({
      fullHost: new providers.HttpProvider('https://api.trongrid.io'),
      // headers: { "TRON-PRO-API-KEY": 'your api key' }, -- if using a custom RPC
      privateKey: TRON_PRIVATE_KEY
    })
    const tokenConfig = chainConfig.tokens[token]
    const amountWithDecimals = +amount * 10 ** tokenConfig.decimals
    const tokenAddress = tokenConfig.address
    const bridgeContractAddress = chainConfig.contractAddress

    const {
      abi
    } = await tronWeb.trx.getContract(tokenAddress);

    const trc20Contract = tronWeb.contract(abi.entrys, tokenAddress);
    const allowance = await trc20Contract.allowance(tronWalletAddress, bridgeContractAddress).call();
    const formattedAllowance = parseInt(allowance, 10) / 10 ** tokenConfig.decimals;

    if (formattedAllowance < parseFloat(amount)) {
       await trc20Contract.approve(bridgeContractAddress, amountWithDecimals).send()
    }

    const contract = tronWeb.contract(bridgeAbi, bridgeContractAddress)
    const tx = await contract.depositWithId(tokenAddress, amountWithDecimals, `0x${commitmentId}`).send({shouldPollResponse: true})

    return tx
  }
  ```
</CodeGroup>
