# How to Mint and Retire TRU Tokens

### Contract Addresses

#### TRU Token Contract

`0xf65B5C5104c4faFD4b709d9D60a185eAE063276c`

This is the ERC-20 token contract for TRU on Ethereum mainnet.

#### Purchase Contract&#x20;

`0x764C64b2A09b09Acb100B80d8c505Aa6a0302EF2`

This is the contract that handles minting and retiring TRU tokens in exchange for ETH.

### Minting TRU Tokens

Minting (purchasing) TRU tokens requires ONE transaction.

#### Function Call

Function: `buyTRU(uint256 amount)`

Parameters:

* `amount` - The number of TRU tokens you want to purchase (in wei units, where 1 TRU = 10^18 wei)

Payment: You must send ETH with this transaction. The amount of ETH required depends on the current TRU/ETH price in the reserve.

So first you will need to request the ETH/TRU price with `getPurchasePrice()`\
This will return the value you will need to send in the buyTRU function.

#### ABI for buyTRU

```json
[
  {
    "constant": false,
    "inputs": [
      {
        "name": "amount",
        "type": "uint256"
      }
    ],
    "name": "sellTRU",
    "outputs": [],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "numTRU",
        "type": "uint256"
      }
    ],
    "name": "getPurchasePrice",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "numTRU",
        "type": "uint256"
      }
    ],
    "name": "getRetirePrice",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  }
]
```

### Retiring TRU Tokens

Retiring (selling) TRU tokens requires TWO transactions.

#### Transaction 1: Approve

Before you can retire TRU tokens, you must first approve the Purchase contract to spend your TRU tokens.

Contract: TRU Token Contract (`0xf65B5C5104c4faFD4b709d9D60a185eAE063276c)`

Function: `approve(address spender, uint256 amount)`

Parameters:

* `spender` - The Purchase contract address: `0x764c64b2a09b09acb100b80d8c505aa6a0302ef2`
* `amount` - The number of TRU tokens you want to retire (in wei units)

#### ABI for approve (ERC-20 Standard)

```json
{
  "constant": false,
  "inputs": [
    {
      "name": "spender",
      "type": "address"
    },
    {
      "name": "amount",
      "type": "uint256"
    }
  ],
  "name": "approve",
  "outputs": [
    {
      "name": "",
      "type": "bool"
    }
  ],
  "payable": false,
  "stateMutability": "nonpayable",
  "type": "function"
}
```

#### Transaction 2: Retire

After approval, you can retire your TRU tokens for ETH.

Contract: Purchase Contract (<kbd>`0x764c64b2a09b09acb100b80d8c505aa6a0302ef2`</kbd>)

Function: `sellTRU(uint256 amount)`

Parameters:

* `amount` - The number of TRU tokens to retire (in wei units, must match or be less than your approved amount)

Returns: You will receive ETH from the reserve in exchange for your TRU tokens.

#### ABI for sellTRU

```json5
{
  "constant": false,
  "inputs": [
    {
      "name": "amount",
      "type": "uint256"
    }
  ],
  "name": "sellTRU",
  "outputs": [],
  "payable": false,
  "stateMutability": "nonpayable",
  "type": "function"
}
```

### Important Notes

1. Token Units: All amounts must be specified in wei (1 TRU = 1 × 10^18 wei). Make sure to include 18 decimal places when specifying amounts.
2. Reserve Mechanics: <https://medium.com/truebit/getting-started-with-truebit-on-ethereum-ac1c7cdb0907>
3. Price Information: The current purchase and retire prices can be obtained by querying the Purchase contract before making transactions.&#x20;
4. Network: All operations occur on Ethereum mainnet. Ensure you're connected to the correct network and have sufficient ETH for gas fees.
5. TRU tokens are available for purchase and retirement also through Truebit OS, See [here](https://docs.truebit.io/v1docs/getting-started/master) for access.

### Contract Verification

All contracts are verified on Etherscan:

* TRU Token:[ View on Etherscan](https://etherscan.io/token/0xf65B5C5104c4faFD4b709d9D60a185eAE063276c)
* Purchase Contract:[ View on Etherscan](https://etherscan.io/address/0x764c64b2a09b09acb100b80d8c505aa6a0302ef2)<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://devs.truebit.io/community/faq/how-to-mint-and-retire-tru-tokens.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
