Deploying an FAssets Agent#
The FAssets agents play an essential role and help to run the system, allowing tokens on blockchains that do not support smart contracts to be used trustlessly with smart contracts on the Flare blockchain.
This guide provides the following information:
- How to set up the FAssets command line interface;
- How to set up access keys for interacting with the Flare test and test XRP Ledger network;
- How to set up an FAssets agent and provide collateral;
- How to run the agent so FAssets system users can convert (mint and redeem) assets from the testnet XRP Ledger to the Flare test network and back.
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.
Contract Addresses#
These are important FAssets smart contract addresses representing test tokens and notable system components, provided for your convenience during the Open Beta on the Coston test network. Please note that these addresses are exclusive to the Coston test network and unavailable on other Flare networks.
Test Tokens#
These are ERC-20 representations of test tokens to be used by the FAssets system:
FAssets System Contracts#
-
AgentOwnerRegistry
: 0xDb6c11b8D074D4488f5fFd0129AA5F91C4f00fb6Allows whitelisting agents, and setting, and retrieving information like their work and management address, name, description and icon.
-
FTestXRP
: 0x5905Df703221d4Ea311E85edEa860734b2072C7dThe FAsset-wrapped TestXRP token, ready to be used on Coston.
Prerequisites#
To participate in the open beta, 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 will 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#
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.
-
Clone the repository and enter the working directory:
git clone https://github.com/flare-labs-ltd/fasset-bots.git cd fasset-bots
-
Switch to the
open_beta
branch:git checkout open_beta
-
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.
-
Copy the environment file from a template
.env.template
to.env
:cp .env.template .env
Configure the Access Keys#
The FAsset agents operate with multiple keys for the Flare and underlying network chains. You should generate these keys to make the agent operational.
-
Create or use an existing management wallet that will be your agent's management address. Fund this wallet with some CFLR so you can pay the gas fees for various smart contract calls using the Flare faucet.
-
Generate the secrets using this command by replacing the
MANAGEMENT_WALLET_ADDRESS
with your cold wallet address:yarn key-gen generateSecrets --user --agent MANAGEMENT_WALLET_ADDRESS --other -o secrets.json
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 designed to be used as hot wallets and should not hold large amounts of tokens, since their private keys are accessible on a machine that is permanently online. Instead, it's best to keep your main account in an offline wallet and transfer funds to these hot wallets as needed. -
Follow the whitelisting process to grant your agent's management address access to the FAssets system. While waiting for approval, you can proceed to the next steps.
-
The
secrets.json
file contains theowner.native.address
field, representing the Flare account responsible for funding agent vaults and covering gas fees for smart contract calls. Please ensure this wallet has enough CFLR tokens to cover gas fees for smart contract calls. You can obtain CFLR tokens from the Flare faucet. -
Prevent other users from reading the
secrets.json
file:chmod 600 secrets.json
-
Fill the
native_rpc
,xrp_rpc
andindexer
fields in thesecrets.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.
Whitelist the Management Address#
To access the FAssets system during the open beta, you must be whitelisted for security reasons. This ensures only authorized participants interact with the system, maintaining a secure and controlled environment for testing and platform improvement. The whitelisting process will be removed after the opening beta.
- Find your agent owner address, which is the value from the
secrets.json
file in theowner.management.address
field. - Use the FlareFAssetsBot Telegram channel, specifically designed for registration, and provide the necessary information, including your agent name, description, and a link to your icon.
- Enter the information and confirm, and the Telegram bot will inform you about the successful process.
- You need to wait for Flare support engineers to approve registrations and issue test assets such as Coston Flare (CFLR), testUSDC, testUSDT, and testETH assets, which will be sent to your
owner.management.address
. While you wait, you can continue with the rest of this guide. - If the information you entered is correct, the Telegram Bot will notify you that you have been whitelisted for the FAssets Open Beta.
Check Whitelist Status#
Checking if your agent's management address has been whitelisted is a straightforward process. Follow these steps:
- Navigate with the Coston block explorer to
AgentOwnerRegistry
smart contract on address 0xDb6c11b8D074D4488f5fFd0129AA5F91C4f00fb6 and open the Read Contract tab. - Connect your wallet with any address to the block explorer so you can gain access to read functions from the smart contract.
- Execute the
isWhitelisted
function with the value ofowner.management.address
from thesecrets.json
file. This function returnsbool
:true
for whitelisted orfalse
for not whitelisted.
Setting Up the Agent#
Configure the Native Address#
Configuring the native address links your agent's work address to the management address and grants access.
-
Navigate with the Coston block explorer to
AgentOwnerRegistry
smart contract on address 0xDb6c11b8D074D4488f5fFd0129AA5F91C4f00fb6 and open the Write Contract tab. -
Connect the cold wallet you used to generate the access keys.
-
Register the work address by executing the
setWorkAddress
function with the value ofowner.native.address
from thesecrets.json
file.
Configure the Agent#
You need to set up your agent's parameters like name, collateral, and fund with underlying assets.
-
Prepare the agent settings
tmp.agent-settings.json
file:yarn agent-bot --fasset FTestXRP create --prepare
-
Choose a suffix for your agent's collateral pool and fill in the
poolTokenSuffix
field in thetmp.agent-settings.json
file with it. ThepoolTokenSuffix
should only include uppercase letters, numbers, and the-
symbol. This suffix will be used for the FAsset Collateral Pool Token. For example, if you useMY-ALPHA-AGENT-1
, it would beFCPT-TXRP-MY-ALPHA-AGENT-1
. -
Choose one of the stable tokens (
testUSDT
ortestUSDC
) or wrapped ETH invaultCollateralFtsoSymbol
to back up the agent vault collateral. -
In the
secrets.json
file, theowner.testXRP.address
field is the underlying testnet XRP Ledger account that pays the underlying chain's transaction fees. Activate your underlying XRP Ledger account by sending at least 100 test-XRP to it by using one of the XRP Ledger testnet faucets: -
Create the agent by specifying the FAsset and agent settings, noting that this operation can take up to 10 minutes because the FAssets verifies the underlying assets. This command will print out your agent's address.
yarn agent-bot --fasset FTestXRP create tmp.agent-settings.json
Deposit Collateral#
To make your newly created agent public, it must hold enough collateral to mint one lot.
This means its agent vault contract needs to be funded with the two collaterals (CFLR and a stablecoin or wrapped ETH) held by your owner.native.address
.
Flare support sends test assets to your owner.management.address
, so remember to move these funds to the owner.native.address
.
You have two options: either deposit the vault collateral and buy pool collateral separately or use the system function to calculate the needed collateral for you.
Deposit Collaterals Together#
To deposit both vault and pool collateral together and let the tool calculate the minimum required collateral to back the lots, you can use the depositCollateral
function to the agent, specifying your created agent address in the AGENT_ADDRESS
and lot size in the LOTS
:
yarn agent-bot depositCollaterals AGENT_ADDRESS LOTS --fasset FTestXRP
Deposit Collateral Separately#
-
Deposit enough vault collateral to the agent specifying your created agent address in the
AGENT_ADDRESS
and the amount of the stablecoin or wrapped ETH in theAMOUNT
field.yarn agent-bot depositVaultCollateral AGENT_ADDRESS AMOUNT --fasset FTestXRP
-
Buy enough pool collateral for the agent specifying your agent's address in the
AGENT_ADDRESS
and the amount of the CFLR in theCFLR_AMOUNT
field.yarn agent-bot buyPoolCollateral AGENT_ADDRESS CFLR_AMOUNT --fasset FTestXRP
Register the Agent as Available#
You need to make your agent available to mint and redeem FAssets.
-
Register your agent as available to the network by executing this command replacing the
AGENT_ADDRESS
with your agent address:yarn agent-bot enter AGENT_ADDRESS --fasset FTestXRP
Info
Note that your agent owner's Flare account has to be whitelisted via the FlareFAssetsBot Telegram channel. Otherwise, it will fail.
-
If you deposited enough collateral, you should see that your agent has at least one lot available by running the command.
yarn user-bot agents --fasset FTestXRP
If you don't have available lots, check if the vault and pool collaterals are enough.
Running the Agent#
The agent bot responds to all requests made to the agent vaults you have created. To run the agent bot, you need to run the following command:
yarn run-agent
When you want to stop the server, press Ctrl + C.
Info
Run the run-agent as a service to maximize uptime for production use. Here, you have instructions to run the agent as a systemd
service for running the bot as a daemon.
Verifying Collateral Pool Smart Contracts#
Verification of a smart contract on a block explorer allows future users of the smart contract to inspect the Solidity source code instead of the bytecode, greatly improving the security and transparency of the ecosystem. Follow these steps to upload the source code for the Collateral Pool and Collateral Pool Token smart contracts, verifying them on the Original Flare block explorer.
-
Execute the FAssets system information command to determine your collateral pool smart contract address.
yarn agent-bot info AGENT_ADDRESS --fasset FTestXRP
Look for the value of the Agent collateral pool field and copy the address
Tokens: Native token: CFLR Wrapped native token: WCFLR FAsset token: FTestXRP Underlying token: testXRP Vault collateral token: testETH Collateral pool token: FCPT-SIMX-KGR-25061612 Network exchange rates: CFLR/USD: 0.033 testETH/USD: 3800 testXRP/USD: 0.53 Agent mint and collateral: Status: healthy Public: true Free lots: 10 Minted: 0 FTestXRP (0 lots) Reserved: 0 FTestXRP (0 lots) Redeeming: 0 FTestXRP (0 lots) Vault CR: <inf> (minCR=1.4, mintingCR=1.6) Pool CR: <inf> (minCR=2, mintingCR=2.4) Free vault collateral: 0.046863112858734529 testETH (10 lots) Free pool collateral: 8071.878095157464265083 WCFLR (10 lots) Lots: Lot size: 20 testXRP Lot vault collateral: 0.004463157894736842 testETH Lot pool collateral: 770.909090909090909091 CFLR Agent address (vault): 0xa6d7dF2d68b4b687d7408Cd613192103DBdA1F33 Balance: 0.046863112858734529 testETH Balance: 8071.878095157464265083 FCPT-SIMX-KGR-25061612 Agent collateral pool: 0x5Bf5cD267F5a5185d0d91567979CCa397A2E504a Balance: 8071.878095157464265083 WCFLR Collected fees: 0 FTestXRP Agent vault underlying (testXRP) address: r4aiumSs3xrSeeeQ9frhrDkhJ6dL1Sr1iL Actual balance: 10 testXRP Tracked balance: 0 testXRP Required balance: 0 testXRP Free balance: 0 testXRP Agent owner management address: 0x6827101103BE87eDadf77202F8973c5046245401 Balance: 90.4216184475 CFLR Balance: 0 testETH Agent owner work address: 0xEfA4D9561fEc607eAe35D76a8034d9dBBe730449 Balance: 4105.334310744331909805 CFLR (5 lots) Balance: 0.042177240174410518 testETH (9 lots) Agent owner underlying (testXRP) address: rndED5w8xQ2sVC2hT5J5e8GTfxouRcKfjR Balance: 40.27988 testXRP
-
Clone the FAsset repository in a new directory and enter it:
git clone https://github.com/flare-labs-ltd/fassets.git cd fassets
-
Switch to the
open_beta
branch:git checkout open_beta
-
Install dependencies and build the project:
yarn && yarn c
Info
A fresh build can take more than 10 minutes, depending on if you have cached dependencies before.
-
Verify the Collateral Pool and Collateral Pool Token smart contracts by running the following command and specifying the collateral pool address that you obtained in the first step as
AGENT_POOL_ADDRESS
:yarn verify-collateral-pool-coston AGENT_POOL_ADDRESS
Verifying the smart contract on the blockchain will take a minute or two, and you should get an output stating that Collateral Pool and Collateral Pool Token smart contracts have been verified. It should be similar to this:
Verifying CollateralPool at 0x5Bf5cD267F5a5185d0d91567979CCa397A2E504a Successfully submitted source code for contract contracts/fasset/implementation/CollateralPool.sol:CollateralPool at 0x5Bf5cD267F5a5185d0d91567979CCa397A2E504a for verification on the block explorer. Waiting for verification result... Successfully verified contract CollateralPool on the block explorer. https://coston-explorer.flare.network/address/0x5Bf5cD267F5a5185d0d91567979CCa397A2E504a#code Verifying CollateralPoolToken at 0x63937c0AD9506C61B2Fca6103E1828E2fcEf8a08 Successfully submitted source code for contract contracts/fasset/implementation/CollateralPoolToken.sol:CollateralPoolToken at 0x63937c0AD9506C61B2Fca6103E1828E2fcEf8a08 for verification on the block explorer. Waiting for verification result... Successfully verified contract CollateralPoolToken on the block explorer. https://coston-explorer.flare.network/address/0x63937c0AD9506C61B2Fca6103E1828E2fcEf8a08#code
Visit the original Flare block explorer at the address of the contract you just verified:
https://coston-explorer.flare.network/address/{AGENT_POOL_ADDRESS}
And check that the Code tab has a green checkmark next to it.