Skip to main content

Flare Smart Accounts

The Flare Smart Accounts is an account abstraction that allows XRPL users to perform actions on the Flare chain without owning any FLR token. Each XRPL address is assigned a unique smart account on the Flare chain, which only it can control. They do so through Payment transactions on the XRPL. The Flare Smart Accounts are especially useful as a way of interacting with the FAssets workflow.

Workflow

The workflow for Flare Smart Accounts is comprised of the following steps.

  1. The XRPL user sends instructions as a Payment transaction to a specific XRPL address, with instructions encoded as the payment reference in the memo field.
  2. The operator interacts with the Flare Data Connector to procure a Payment proof. It then calls the executeTransaction function on the MasterAccountController contract, with the Payment proof and the XRPL address that made the transaction.
  3. The XRPL user's smart account performs the actions given in the instructions.

1. Instructions on XRPL

The Flare Smart Accounts allow XRPL users to perform actions on the Flare chain through instructions on the XRPL. This is done through a Payment to an XRPL address, designated by the operator, a backend monitoring incoming transactions and interacting with the Flare chain. The payment must transfer sufficient funds, as specified by the operator, and must include the proper payment receipt in the memo field.

The payment receipt is a bytes32 value. The first byte is reserved for the instruction code. The second byte is a wallet identifier; this is a number assigned to wallet providers by the Flare Foundation, and should otherwise be 0. The remaining 31 bytes are the parameters for the chosen instruction.

In practice, the payment receipt should be prepared by a backend, through a web form.

The first, instruction code, byte is further subdivided into two half-bytes. The first nibble is the instruction type; this is either FXRP, Firelight, or Upshift (with corresponding type IDS 0, 1, and 2). The second nibble is the instruction command; the available commands are different for each instruction type.

Table of instruction IDs and corresponding actions.

FXRP

Instructions for interacting with the FXRP token.

Type ID: 00.

 Command IDAction Description 
 00 collateralReservation

 Reserve a value of lots of collateral in the agent vault, registered with the agentVaultId with the MasterAccountController contract.

 01 transfer

 Transfer a value (in drops) of FXRP to the recipientAddress.

 02 redeem Redeem a value of lots of FXRP.

 

Firelight

Instructions for interacting with a Firelight-type vault.

Type ID: 01.

 Command IDAction Description 
 00 collateralReservationAndDeposit

 Reserve a value of lots of collateral in the agent vault, registered with the agentVaultId with the MasterAccountController contract. After successful minting, deposit the FXRP into the Firelight type vault, registered with the vaultId with the MasterAccountController contract. Equivalent to sending a collateralReservation instruction and a Firelight deposit instruction.

 01 deposit

 Deposit a value of FXRP into the Firelight type vault, registered with the vaultId with the MasterAccountController contract.

 02 redeem

 Start the withdrawal process for a value of FXRP from the Firelight type vault, registered with the vaultId, with the MasterAccountController contract.

 03 claimWithdraw

 Withdraw the FXRP, requested in the value period, from Firelight type vault, registered with the vaultId, with the MasterAccountController contract.

 

Upshift

Instructions for interacting with an Upshift-type vault.

Type ID: 02.

 Command IDAction Description 
 00 collateralReservationAndDeposit

 Reserve a value of lots of collateral in the agent vault, registered with the agentVaultId with the MasterAccountController contract. After successful minting, deposit the FXRP into the Upshift type vault, registered with the vaultId, with the MasterAccountController contract. Equivalent to sending a collateralReservation instruction and a Upshift deposit instruction.

 01 deposit

 Deposit a value of FXRP into the Upshift type vault, registered with the vaultId with the MasterAccountController contract.

 02 requestRedeem

 Start the withdrawal process for a value of FXRP from the Upshift type vault, registered with the vaultId with the MasterAccountController contract.

 03 claim

 Withdraw the FXRP, requested in the value period, from Upshift type vault, registered with the vaultId with the MasterAccountController contract.

 

2. Payment proof on Flare

The operator monitors incoming transactions to the specified XRPL address. Upon receiving a payment, it makes a Payment attestation request to the FDC. The Payment proof and the user's XRPL address are passed to the executeTransaction function on the MasterAccountController smart contract on the Flare chain.

The MasterAccountController contract first verifies the proof. It then performs several checks on the proof:

  • receiving address matches the one specified by the operator,
  • the source address matches the XRPL address given to the function,
  • that the proof has not yet been used for the same actions.

Then, the MasterAccountController contract retrieves the XRPL user's smart account from a mapping. If the account does not yet exist, it is created at this point.

The payment reference is decoded. Depending on the value of the leading byte, a different function on the smart account is called.

3. Actions on Flare

The XRPL user's smart account performs the actions in the instructions.