Skip to content

Using the Command Line to Mint and Redeem FAssets#

Users of the FAssets system can mint and redeem FAssets, allowing tokens on blockchains that do not support smart contracts to be used trustlessly with smart contracts on the Flare blockchain.

This guide is for advanced users who having some experiencing using a terminal. It provides the following information:

  • How to set up the FAssets command-line tool.
  • How to convert testnet XRP to FAssets (FTestXRP) on the Flare test network (minting).
  • How to convert FAssets (FTestXRP) from Flare test network back to testnet XRP Ledger network (redemption).

Alternatively, you can use the dapp to mint and redeem FAssets.

Open Beta

The FAssets system is currently in the Open Beta period. During this phase, user-friendly tools are still being developed.

Some web browsers and ad blockers might prevent this functionality.

Alternatively, you can contact support@flarelabs.org.

Prerequisites#

You need a server with at least a minimum of 2 CPUs and 4GB RAM, or 2GB if the database is on a separate server.

You need knowledge of the following tools:

Warning

If you are using Windows, it is strongly recommended to use Windows Subsystem for Linux, version 2 (WSL 2).

Setting up the FAssets tools#

Setting up After Testnet XRP Reset#

Info

This section is only for users using FAssets before the testnet XRP reset, so please read more.

Suppose you previously ran the FAssets agent before the XRP testnet reset. You will need to skip the whitelisting part but still need to:

  • pull the latest changes from the repository by git pull;
  • build then with yarn && yarn build;
  • installing the MySQL database and setting it up following the guide later in this document;
  • create a new agent using the existing management address following the guide.

Clone and Setup the Tools Repository#

Info

If you set up an FAssets agent, bot or user, please use a separate directory for each role.

  1. Clone the repository and enter the working directory:

    git clone https://github.com/flare-labs-ltd/fasset-bots.git
    cd fasset-bots
    
  2. Switch to the open_beta branch:

    git checkout open_beta
    
  3. Install dependencies and build the project:

    yarn && yarn build
    

    Info

    Fresh installation can take more than 10 minutes, depending on if you have cached dependencies before.

  4. Copy the environment file from a template .env.template to .env:

    cp .env.template .env
    

Configure User's Access Keys#

The FAsset user operates with multiple keys for the Flare and underlying network chains.

  1. Generate the user's secrets using this command:

    yarn key-gen generateSecrets --user -o secrets.json
    

    Among other things, this command creates wallets on the XRP Ledger and Flare networks that you will use throughout the rest of this guide.

    Info

    This command can only be executed once, after which all secret keys will be generated. You must use a separate directory for each role you want to perform: agent, bot, or minter and redeemer.

    Warning

    • The addresses in secrets.json are for hot wallets and should not hold large token amounts, as their private keys are on an always-online machine. Keep your main account in an offline wallet and transfer funds as needed.
    • As soon as you create the secrets.json file, back it up, and remember to back it up again whenever you add new keys. Store the backup securely, preferably on an external drive in a physical vault, as unauthorized access can compromise the agent. You need to make regular backups only if you make changes.
  2. Fund the user's FLR wallet with some CFLR to pay the gas fees. You can find the user wallet's address in the secrets.json file under the user.native.address key. You can get the CFLR tokens from the Flare faucet.

  3. Prevent other users from reading the secrets.json file:

    chmod 600 secrets.json
    
  4. Fill the native_rpc, xrp_rpc and indexer fields in the secrets.json file with the following values:

    "native_rpc": "AavSehMLhcgz3crQHH5YJ3Rt8GMQGdV9aViGilADXGnTcjij",
    "xrp_rpc": "4tg3AxysaZodxTqsCtcMnBdBIEkR6KDKGTdqBEA8g9MKq4bH",
    "indexer": "123456",
    

    Info

    These values apply only to the Coston Testnet and will be different for other networks.

Minting FAssets#

  1. Use the command below to list all available agents and their minting fees. Then chose one.

    yarn user-bot --fasset FTestXRP agents
    
  2. Use this command to determine the FAssets lot size, since you will need it next:

    yarn user-bot info -f FTestXRP
    

    You need to find the line in the command output that displays the lot size in this format:

    Lot size: 20 FTestXRP
    
  3. Find your generated XRP Ledger testnet wallet address in user.testXRP.address from the secrets.json file you created above, and fund it using one of the faucets:

    Info

    The minimum amount of FAssets you can mint is one lot, determined by the previous command. Furthermore, agents charge a fee, and you should pay for a transaction on the XRP network. Once you have selected an agent and know its fee, request enough XRP from the faucet to pay for it, plus the transaction cost.

  4. Mint the FTestXRP FAssets by running the following command, replacing AGENT_ADDRESS with an agent address from the list obtained before, and LOTS with the number of lots to mint:

    yarn user-bot mint -a AGENT_ADDRESS LOTS --fasset FTestXRP --secrets secrets.json
    

    Alternatively, you can rely on the FAssets system to automatically select the agent with the lowest fee by removing the -a AGENT_ADDRESS parameter from the previous command:

    yarn user-bot mint LOTS --fasset FTestXRP --secrets secrets.json
    

Redeeming FAssets#

Redeem the FTestXRP for the underlying asset obtained in the previous step by running the following command and replacing LOTS with the number of lots you want to redeem:

yarn user-bot redeem LOTS --fasset FTestXRP --secrets secrets.json

Info

The redemption may take an hour or more for the underlying funds to arrive at the user's address. If the agent pays immediately, redemption takes about 5 minutes. However, if the agent delays, the redeemer must wait 500 testXRP blocks or 900 seconds, plus 5 minutes for Flare Data connector proof, to execute redemption default.