# Introduction

> Introduction to the Flare Smart Accounts CLI.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

Source: https://dev.flare.network/smart-accounts/guides/cli/introduction

The [Flare Smart Accounts CLI](https://github.com/flare-foundation/smart-accounts-cli) is a tool written in Python that streamlines the Flare Smart Accounts process by properly structuring and sending XRPL transactions/instructions. It has commands corresponding to each Flare Smart Accounts action ([table of instructions](/smart-accounts/overview#instructions-on-xrpl)), as well as other useful debugging features.

note

The CLI executes **only** the transaction on XRPL. It does not bridge the instructions to Flare. That is done by the operator - a service that Flare runs.

To use the CLI, first clone [the repository](https://github.com/flare-foundation/smart-accounts-cli) and install the necessary dependencies:

```
git clone https://github.com/flare-foundation/smart-accounts-cli.gitcd smart-accounts-clipip install -r requirements.txt
```

Copy the `.env.example` file to the `.env` file, and fill in the missing values in the latter.

```
cp .env.example .env
```

The missing values are an XRPL testnet account secret value, a Flare address private key, and the RPC URLs for both Flare's Coston2 and XRPL testnet. You can create a new secret string through the [XRP faucets](https://xrpl.org/resources/dev-tools/xrp-faucets).

The script is run in the terminal with a command of the following shape.

```
./smart_accounts.py <command> <positional-argument> ...
```

Here is a list of available commands and their positional arguments:

-   `encode`
    -   `fxrp-cr`: *(legacy)* encode FXRP collateral reservation instruction — not the recommended mint path
    -   `fxrp-transfer`: encode FXRP transfer instruction
    -   `fxrp-redeem`: encode FXRP redeem instruction
    -   `firelight-cr-deposit`: *(legacy)* encode Firelight collateral reservation and deposit — not the recommended mint path
    -   `firelight-deposit`: encode Firelight deposit instruction
    -   `firelight-redeem`: encode Firelight redeem instruction
    -   `firelight-claim-withdraw`: encode Firelight claim withdraw instruction
    -   `upshift-cr-deposit`: *(legacy)* encode Upshift collateral reservation and deposit — not the recommended mint path
    -   `upshift-deposit`: encode Upshift deposit instruction
    -   `upshift-request-redeem`: encode Upshift request redeem instruction
    -   `upshift-claim`: encode Upshift claim instruction
-   `decode`
-   `bridge`
    -   `instruction`: send imputed instruction as a transaction on XRPL
    -   `mint-tx`: *(legacy)* make a deposit to an agent's vault after CRT — not the recommended mint path

Minting FXRP

User minting uses [FAssets minting](/fassets/minting): an XRPL payment to the Core Vault with a memo or destination tag. For mint-and-action in one payment, use a [memo-field custom instruction](/smart-accounts/memo-field-custom-instruction). See [Mint FXRP](/fassets/developer-guides/fassets-mint) and the [Cross-Chain Mint](/smart-accounts/guides/typescript-viem/cross-chain-mint-ts) guide. The CLI `fxrp-cr`, `*-cr-deposit`, and `bridge mint-tx` commands encode the legacy collateral-reservation (CRT) path; they may still exist in `smart_accounts.py` but are not the recommended user mint path.

The positional arguments of the `encode` command correspond to type-command instruction pairs, described in the [FAsset instructions guide](/smart-accounts/fasset-instructions). The `bridge instruction` command makes an XRPL Payment transaction with the imputed instruction as payment reference.

## Using the CLI[​](#using-the-cli "Direct link to Using the CLI")

The below-described CLI commands are intended to work in tandem with one another. The output of the `encode` command can be sent to the `bridge` command via stdin. Commands can be piped in the following way.

```
<encode_command> | ./smart_accounts.py bridge instruction -
```

Legacy CRT mint piping

Piping `fxrp-cr` / `*-cr-deposit` into `bridge instruction` and then `bridge mint-tx` is the legacy collateral-reservation mint path. Prefer [FAssets minting](/fassets/minting) for minting, then use CLI encode + `bridge instruction` only for transfer, deposit, redeem, and claim.

This is described in more detail in the [Bridge section](/smart-accounts/guides/cli/introduction#bridge) of this guide.

## Encode[​](#encode "Direct link to Encode")

Encode and instruction with given parameters. The parameters are unique to each command.

There is one parameter that all the commands have in common, `walletId`. The `walletId` is a Flare-designated parameter, intended for wallet identification by the operator. It has no impact on the result of the action performed. If no number has been provided to you, set the `walletId` to `0`.

```
./smart_accounts.py encode <command> --wallet-id <walletId> ...
```

### FXRP[​](#fxrp "Direct link to FXRP")

Smart account instructions for interacting with the base FAsset system. Each of these commands starts with the `fxrp` keyword.

#### Collateral reservation (legacy)[​](#collateral-reservation-legacy "Direct link to Collateral reservation (legacy)")

Legacy

`fxrp-cr` encodes the deprecated collateral-reservation (CRT) mint path. Mint FXRP via [FAssets minting](/fassets/minting) instead. This command may still exist in `smart_accounts.py` but is not the recommended user mint path.

```
./smart_accounts.py encode fxrp-cr --wallet-id <walletId> --value <value> --agent-vault-id <agentVaultId>
```

<details>
<summary>Example values and expected output</summary>

Example values and expected output

```
./smart_accounts.py encode fxrp-cr --wallet-id 0 --value 1 --agent-vault-id 1
```

The above command produces the following output:

```
0x0000000000000000000000010001000000000000000000000000000000000000
```

</details>

#### Transfer[​](#transfer "Direct link to Transfer")

Transfer `value` FXRP from your personal account to the `recipientAddress` on Flare. The `walletId` is a Flare-designated parameter, intended for wallet identification by the operator. It has no impact on the result of the action performed. If no number has been provided to you, set the `walletId` to `0`.

```
./smart_accounts.py encode fxrp-transfer \  --wallet-id <walletId> \  --value <value> \  --recipient-address <recipientAddress>
```

<details>
<summary>Example values and expected output</summary>

Example values and expected output

```
./smart_accounts.py encode fxrp-transfer \  --wallet-id 0 \   --value 1 \  --recipient-address "0xf5488132432118596fa13800b68df4c0ff25131d"
```

The above command produces the following output:

```
0x010000000000000000000001f5488132432118596fa13800b68df4c0ff25131d
```

</details>

#### Redeem[​](#redeem "Direct link to Redeem")

Redeem `value` lots of FXRP back to XRP. That number of lots of FXRP are burned from the user's smart account, and the same amount of XRP is sent to the user's address on XRPL. The `walletId` is a Flare-designated parameter, intended for wallet identification by the operator. It has no impact on the result of the action performed. If no number has been provided to you, set the `walletId` to `0`.

```
./smart_accounts.py encode fxrp-redeem --wallet-id <walletId> --value <value>
```

<details>
<summary>Example values and expected output</summary>

Example values and expected output

```
./smart_accounts.py encode fxrp-redeem --wallet-id 0 --value 1
```

The above command produces the following output:

```
0x0200000000000000000000010000000000000000000000000000000000000000
```

</details>

### Firelight[​](#firelight "Direct link to Firelight")

Smart account instructions for interacting with a Firelight-type vault. Each of these commands starts with the `firelight` keyword.

#### Collateral reservation and deposit (legacy)[​](#collateral-reservation-and-deposit-legacy "Direct link to Collateral reservation and deposit (legacy)")

Legacy

`firelight-cr-deposit` encodes the deprecated CRT mint-and-deposit path. Mint via [FAssets minting](/fassets/minting), then use `firelight-deposit`. For mint-and-deposit in one XRPL payment, use a [memo-field custom instruction](/smart-accounts/memo-field-custom-instruction).

```
./smart_accounts.py encode firelight-cr-deposit \ --wallet-id <walletId> \ --value <value> \ --agent-vault-id <agentVaultId> \ --vault-id <vaultId>
```

<details>
<summary>Example values and expected output</summary>

Example values and expected output

```
./smart_accounts.py encode firelight-cr-deposit --wallet-id 0 --value 1 --agent-vault-id 1 --vault-id 1
```

The above command produces the following output:

```
0x1000000000000000000000010001000100000000000000000000000000000000
```

</details>

#### Deposit[​](#deposit "Direct link to Deposit")

Deposit `vault` drops of FXRP into the Firelight-type vault, registered with the `MasterAccountController` contract with the `vaultId`. The complete list of the registered vaults can be obtained from the `MasterAccountController` contract.

warning

The registered vaults can be of either the Firelight- or Upshift-type, so make sure that you choose the right one for the instruction you are sending.

The `walletId` is a Flare-designated parameter, intended for wallet identification by the operator. It has no impact on the result of the action performed. If no number has been provided to you, set the `walletId` to `0`.

```
./smart_accounts.py encode firelight-deposit --wallet-id <walletId> --value <value> --vault-id <vaultId>
```

<details>
<summary>Example values and expected output</summary>

Example values and expected output

```
./smart_accounts.py encode firelight-deposit --wallet-id 0 --value 1 --vault-id 1
```

The above command produces the following output:

```
0x1100000000000000000000010000000100000000000000000000000000000000
```

</details>

#### Redeem[​](#redeem-1 "Direct link to Redeem")

Begin the withdrawal process from the Firelight-type vault. A `value` of drops FXRP is marked to be withdrawn from the Firelight-type vault, registered with the `MasterAccountController` contract with the `vaultId`, to the user's personal account.

In the process, the vault emits an event with the `period` parameter. This value is required in the second part of the withdrawal process.

The `walletId` is a Flare-designated parameter, intended for wallet identification by the operator. It has no impact on the result of the action performed. If no number has been provided to you, set the `walletId` to `0`.

```
./smart_accounts.py encode firelight-redeem --wallet-id <walletId> --value <value> --vault-id <vaultId>
```

<details>
<summary>Example values and expected output</summary>

Example values and expected output

```
./smart_accounts.py encode firelight-redeem --wallet-id 0 --value 1 --vault-id 1
```

The above command produces the following output:

```
0x1200000000000000000000010000000100000000000000000000000000000000
```

</details>

#### Claim withdraw[​](#claim-withdraw "Direct link to Claim withdraw")

Complete the withdrawal process from the Firelight-type vault, registered with the `MasterAccountController` contract with the `vaultId`. After the withdrawal process has been started, the funds are locked for a certain amount of time. Once that period has passed, they can be transferred back to the user's personal account.

When the withdrawal is requested, a period value is exposed in the event that is emitted. The period must be included in the claim withdrawal instruction as the `value` parameter.

The `walletId` is a Flare-designated parameter, intended for wallet identification by the operator. It has no impact on the result of the action performed. If no number has been provided to you, set the `walletId` to `0`.

```
./smart_accounts.py encode firelight-claim-withdraw \  --wallet-id <walletId> \  --value <value> \  --vault-id <vaultId>
```

<details>
<summary>Example values and expected output</summary>

Example values and expected output

```
./smart_accounts.py encode firelight-claim-withdraw --wallet-id 0 --value 123456789 --vault-id 1
```

The above command produces the following output:

```
0x1300000000000000075bcd150000000100000000000000000000000000000000
```

</details>

### Upshift[​](#upshift "Direct link to Upshift")

Smart account instructions for interacting with an Upshift-type vault. Each of these commands starts with the `upshift` keyword.

#### Collateral reservation and deposit (legacy)[​](#collateral-reservation-and-deposit-legacy-1 "Direct link to Collateral reservation and deposit (legacy)")

Legacy

`upshift-cr-deposit` encodes the deprecated CRT mint-and-deposit path. Mint via [FAssets minting](/fassets/minting), then use `upshift-deposit`. For mint-and-deposit in one XRPL payment, use a [memo-field custom instruction](/smart-accounts/memo-field-custom-instruction).

```
./smart_accounts.py encode upshift-cr-deposit \ --wallet-id <walletId> \ --value <value> \ --agent-vault-id <agentVaultId> \ --vault-id <vaultId>
```

<details>
<summary>Example values and expected output</summary>

Example values and expected output

```
./smart_accounts.py encode upshift-cr-deposit --wallet-id 0 --value 1 --agent-vault-id 1 --vault-id 2
```

The above command produces the following output:

```
0x2000000000000000000000010001000200000000000000000000000000000000
```

</details>

#### Deposit[​](#deposit-1 "Direct link to Deposit")

Deposit `vault` drops of FXRP into the Upshift-type vault, registered with the `MasterAccountController` contract with the `vaultId`. The complete list of the registered vaults can be obtained from the `MasterAccountController` contract.

warning

The registered vaults can be of either the Firelight- or Upshift-type, so make sure that you choose the right one for the instruction you are sending.

The `walletId` is a Flare-designated parameter, intended for wallet identification by the operator. It has no impact on the result of the action performed. If no number has been provided to you, set the `walletId` to `0`.

```
./smart_accounts.py encode upshift-deposit --wallet-id <walletId> --value <value> --vault-id <vaultId>
```

<details>
<summary>Example values and expected output</summary>

Example values and expected output

```
./smart_accounts.py encode upshift-deposit --wallet-id 0 --value 1 --vault-id 2
```

The above command produces the following output:

```
0x2100000000000000000000010000000200000000000000000000000000000000
```

</details>

#### Request redeem[​](#request-redeem "Direct link to Request redeem")

Begin the withdrawal process from an Upshift-type vault. A `value` of drops FXRP is marked to be withdrawn from the Upshift-type vault, registered with the `MasterAccountController` contract with the `vaultId`, to the user's personal account.

In the process, the vault emits an event with the `period` parameter. This value is required in the second part of the withdrawal process.

The `walletId` is a Flare-designated parameter, intended for wallet identification by the operator. It has no impact on the result of the action performed. If no number has been provided to you, set the `walletId` to `0`.

```
./smart_accounts.py encode upshift-request-redeem \  --wallet-id <walletId> \  --value <value> \  --vault-id <vaultId>
```

<details>
<summary>Example values and expected output</summary>

Example values and expected output

```
./smart_accounts.py encode upshift-request-redeem --wallet-id 0 --value 1 --vault-id 2
```

The above command produces the following output:

```
0x2200000000000000000000010000000200000000000000000000000000000000
```

</details>

#### Claim[​](#claim "Direct link to Claim")

Complete the withdrawal process from the Upshift-type vault, registered with the `MasterAccountController` contract with the `vaultId`. After the withdrawal process has been started, the funds are locked for a certain amount of time. Once that period has passed, they can be transferred back to the user's personal account.

The `value` parameter is the date when the redemption was requested. It should be given as an 8-digit number `YYYYMMDD`, where `YYYY` is the year, `MM` the month (from `1` to `12`) and `DD` (from `1` to `31`) the day of the redemption request.

The `walletId` is a Flare-designated parameter, intended for wallet identification by the operator. It has no impact on the result of the action performed. If no number has been provided to you, set the `walletId` to `0`.

```
./smart_accounts.py encode upshift-claim --wallet-id <walletId> --value <value> --vault-id <vaultId>
```

<details>
<summary>Example values and expected output</summary>

Example values and expected output

```
./smart_accounts.py encode upshift-claim --wallet-id 0 --value 20260124 --vault-id 2
```

The above command produces the following output:

```
0x23000000000000000135251c0000000200000000000000000000000000000000
```

</details>

## Bridge[​](#bridge "Direct link to Bridge")

The bridge command makes an XRPL Payment transaction on behalf of the user, with the given input as the transaction memo field. There are two positional arguments, `instruction` and `mint-tx`. The `instruction` positional argument signals the user's intent by making an XRPL Payment transaction to the operator's XRPL address, with the instruction attached as the memo field. The `mint-tx` argument is a **legacy** helper for the CRT mint path (sending XRP to an agent's vault after collateral reservation). Prefer [FAssets minting](/fassets/minting) for minting instead.

### Instruction[​](#instruction "Direct link to Instruction")

When the `bridge` command is used with the `instruction` positional argument, it accepts an `encodedInstruction` as input. It makes a Payment transaction to the operator's XRPL address, with the `encodedInstruction` as the memo field of the payment. Finally, it prints the hash of the transaction to the standard output stream.

The `encodedInstruction` can be obtained with the `encode` command.

```
./smart_accounts.py bridge instruction <encodedInstruction>
```

Alternatively, the command can read the input directly from the standard input stream. Since the `encode` command prints the result to the standard output stream, the two commands can be chained together. To do this, the `-` character is used instead of the `transactionHash`.

```
<encode_command> | ./smart_accounts.py bridge instruction -
```

<details>
<summary>Example values and expected output</summary>

Example values and expected output

```
./smart_accounts.py encode fxrp-redeem --wallet-id 0 --value 1 \  | ./smart_accounts.py bridge instruction -
```

The above command encodes an FXRP redeem instruction for `1` lot of FXRP, and sends that instruction as an XRPL Payment transaction. It produces the following output.

```
sent bridge instruction transaction: CD0879CD7398DE4B96A7A7D475EFD0F3585E05D100C84C9E3FE32B34FACF0E39CD0879CD7398DE4B96A7A7D475EFD0F3585E05D100C84C9E3FE32B34FACF0E39
```

The instruction only works if the user's personal account has sufficient FXRP balance.

</details>

### Mint tx (legacy)[​](#mint-tx-legacy "Direct link to Mint tx (legacy)")

Legacy

`bridge mint-tx` completes the deprecated collateral-reservation mint path. Mint FXRP via [FAssets minting](/fassets/minting) (Core Vault payment with memo or tag) instead.

When the `bridge` command is used with the `mint-tx` positional argument, it accepts an XRPL `transactionHash` as input. It then observes the `MasterAccountController` contract for a `CollateralReserved` event that belongs to the transaction with the `transactionHash`. A payment reference is read from the `CollateralReserved` event, and a mint transaction to the agent vault's address is performed.

The transaction must contain a collateral reservation (and deposit) instruction, otherwise the process fails, since no such event is emitted for other instructions.

The `transactionHash` can be obtained by calling the `bridge` command with the `instruction` positional argument.

```
./smart_accounts.py bridge mint-tx <transactionHash>
```

Alternatively, the command can read the input directly from the standard input stream. Since the `encode` and `bridge` commands both print the result to the standard output stream, all three commands can be chained together. To do this, the `-` character is used instead of the `transactionHash`. Additionally, the `--wait` flag must be provided.

```
<encode_command> | ./smart_accounts.py bridge instruction - | ./smart_accounts.py bridge mint-tx --wait -
```

<details>
<summary>Example values and expected output (legacy)</summary>

Example values and expected output (legacy)

```
./smart_accounts.py encode fxrp-cr --wallet-id 0 --value 1 --agent-vault-id 1 \  | ./smart_accounts.py bridge instruction - \  | ./smart_accounts.py bridge mint-tx --wait -
```

The above command encodes a legacy FXRP collateral reservation instruction for `1` lot of FXRP, using the agent vault with ID `1`, and sends that instruction as an XRPL Payment transaction. It then waits for the CRT mint leg. It produces the following output.

```
sent bridge instruction transaction: 659364520199DED473635A9ABFB1C15B945B216A1208679979AB5C05F03E837Csent mint tx: 8401244DD1FA4C295ABC16A0B05CC12F7DBCE34756F12C2F5C3DC1840A5F33168401244DD1FA4C295ABC16A0B05CC12F7DBCE34756F12C2F5C3DC1840A5F3316
```

</details>

## Decode[​](#decode "Direct link to Decode")

The `decode` command is the inverse of the `encode` command. It takes an `encodedInstruction` as input, and decodes it to a Python class that corresponds to the instruction. The `encodedInstruction` can be obtained from the output of the `encode` command.

```
./smart_accounts.py decode <encodedInstruction>
```

Alternatively, the command can read the input directly from the standard input stream. Since the `encode` command prints the result to the standard output stream, the two commands can be chained together. To do this, the `-` character is used instead of the `transactionHash`.

```
<encode_command> | ./smart_accounts.py decode -
```

<details>
<summary>Example values and expected output</summary>

Example values and expected output

```
./smart_accounts.py encode fxrp-redeem --wallet-id 0 --value 1 \  | ./smart_accounts.py decode -
```

The above command encodes an FXRP redeem instruction for `1` lot of FXRP, and then decodes it to an `FxrpRedeem` class. It produces the following output.

```
FxrpRedeem(wallet_id=0, value=1)
```

</details>
