How to Mint and Retire TRU Tokens

This guide provides the smart contract information needed to mint (purchase) and retire (sell) TRU tokens on Ethereum. These operations can be performed directly via smart contract calls.

Contract Addresses

TRU Token Contract

0xf65B5C5104c4faFD4b709d9D60a185eAE063276c

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

Purchase Contract

0x764c64b2a09b09acb100b80d8c50aa6a0302ef2

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

[
  {
    "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)

{
  "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 (0x764c64b2a09b09acb100b80d8c505aa6a0302ef2)

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

{
  "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. Price Information: The current purchase and retire prices can be obtained by querying the Purchase contract before making transactions.

  3. Network: All operations occur on Ethereum mainnet. Ensure you're connected to the correct network and have sufficient ETH for gas fees.

Contract Verification

All contracts are verified on Etherscan:

Last updated

Was this helpful?