You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -28,40 +28,86 @@ The Flare Smart Accounts are especially useful as a way of interacting with the
28
28
29
29
## Workflow
30
30
31
-
The workflow for Flare Smart Accounts is comprised of the following steps.
31
+
Flare Smart Accounts support two complementary flows for turning an XRPL `Payment` into actions on Flare.
32
32
33
-
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.
34
-
2. The operator interacts with the [Flare Data Connector](/fdc/overview) to procure a `Payment` proof.
35
-
It then calls the `executeTransaction` function on the `MasterAccountController` contract, with the `Payment` proof and the XRPL address that made the transaction.
36
-
3. The XRPL user's smart account performs the actions given in the instructions.
33
+
### Proof-based flow (payment reference)
34
+
35
+
1. The XRPL user sends a `Payment` transaction to the operator's XRPL address with a 32-byte instruction encoded as the **payment reference**.
36
+
2. The operator requests a [`Payment` attestation](/fdc/attestation-types/payment) from the [Flare Data Connector](/fdc/overview) and submits it to the `MasterAccountController`.
37
+
3. The XRPL user's `PersonalAccount` performs the action encoded in the reference.
1. The XRPL user sends a `Payment` to an FAssets agent's XRPL address that mints FXRP directly to the smart account, with the [memo field](/smart-accounts/custom-instruction) carrying the instruction.
55
+
2. The FAssets `AssetManager` mints FXRP to the `MasterAccountController` and calls back into [`mintedFAssets`](/smart-accounts/reference/IMasterAccountController#mintedfassets) on `MemoInstructionsFacet`.
56
+
3. The facet routes the FAssets to the user's `PersonalAccount`, optionally pays an executor fee, and dispatches any memo instruction (`0xFF` execute UserOp, `0xE0` ignore memo, `0xE1` set nonce, `0xE2` replace fee, `0xD0`/`0xD1` set/remove executor).
and calls back into `mintedFAssets` (4) → `MasterAccountController` forwards
87
+
FXRP and dispatches the memo to the user's `PersonalAccount` (5).
88
+
</p>
89
+
46
90
## 1. Instructions on XRPL
47
91
48
92
The Flare Smart Accounts allow XRPL users to perform actions on the Flare chain through instructions on the XRPL.
49
93
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.
50
-
The payment must transfer sufficient funds, as specified by the operator, and must include the proper payment receipt in the memo field.
94
+
The payment must transfer sufficient funds, as specified by the operator, and must include the proper payment reference (proof-based flow) or memo (direct-minting flow).
51
95
52
-
The payment receipt is a `bytes32` value.
96
+
The payment reference is a `bytes32` value.
53
97
The first byte is reserved for the instruction code.
54
98
The second byte is a wallet identifier;
55
99
this is a number assigned to wallet providers by the Flare Foundation, and should otherwise be `0`.
56
100
The remaining 30 bytes are the parameters for the chosen instruction.
57
101
58
-
In practice, the payment receipt should be prepared by a backend, through a web form.
102
+
In practice, the payment reference should be prepared by a backend, through a web form.
59
103
60
104
The first, instruction code, byte is further subdivided into two half-bytes.
61
105
The first nibble is the instruction type;
62
106
this is either `FXRP`, `Firelight`, or `Upshift` (with corresponding type IDS `0`, `1`, and `2`).
63
107
The second nibble is the instruction command; the available commands are different for each instruction type.
64
108
109
+
For the direct-minting flow, the memo carries a different layout — see the [Custom Instruction guide](/smart-accounts/custom-instruction) for the `PackedUserOperation` format and the `0xFF`/`0xE0`/`0xE1`/`0xE2`/`0xD0`/`0xD1` instruction codes.
110
+
65
111
<details>
66
112
<summary>Table of instruction IDs and corresponding actions.</summary>
67
113
@@ -71,181 +117,71 @@ Instructions for interacting with the `FXRP` token.
71
117
72
118
**Type ID:**`00`.
73
119
74
-
<table>
75
-
<thead>
76
-
<tr>
77
-
<td> **Command ID**</td>
78
-
<td>**Action** </td>
79
-
<td>**Description** </td>
80
-
</tr>
81
-
</thead>
82
-
<tbody>
83
-
<tr>
84
-
<td> 00</td>
85
-
<td> collateralReservation</td>
86
-
<td>
87
-
Reserve a `value` of lots of collateral in the agent vault,
88
-
registered with the `agentVaultId` with the `MasterAccountController`
89
-
contract.
90
-
</td>
91
-
</tr>
92
-
<tr>
93
-
<td> 01</td>
94
-
<td> transfer</td>
95
-
<td>
96
-
Transfer a `value` (in drops) of FXRP to the `recipientAddress`.
|`00`|`collateralReservation`| Reserve a `value` of lots of collateral in the agent vault, registered with the `agentVaultId` with the `MasterAccountController` contract. |
123
+
|`01`|`transfer`| Transfer a `value` (in drops) of FXRP to the `recipientAddress`. |
124
+
|`02`|`redeem`| Redeem a `value` of lots of FXRP. |
107
125
108
126
### Firelight
109
127
110
128
Instructions for interacting with a Firelight-type vault.
111
129
112
130
**Type ID:**`01`.
113
131
114
-
<table>
115
-
<thead>
116
-
<tr>
117
-
<td> **Command ID**</td>
118
-
<td>**Action** </td>
119
-
<td>**Description** </td>
120
-
</tr>
121
-
</thead>
122
-
<tr>
123
-
<td> 00</td>
124
-
<td> collateralReservationAndDeposit</td>
125
-
<td>
126
-
Reserve a `value` of lots of collateral in the agent vault,
127
-
registered with the `agentVaultId` with the `MasterAccountController`
128
-
contract. After successful minting, deposit the FXRP into the Firelight
129
-
type vault, registered with the `vaultId` with the
130
-
`MasterAccountController` contract. Equivalent to sending a
131
-
`collateralReservation` instruction and a Firelight `deposit` instruction.
132
-
</td>
133
-
</tr>
134
-
<tbody>
135
-
<tr>
136
-
<td> 01</td>
137
-
<td> deposit</td>
138
-
<td>
139
-
Deposit a `value` of FXRP into the Firelight type vault,
140
-
registered with the `vaultId` with the `MasterAccountController`
141
-
contract.
142
-
</td>
143
-
</tr>
144
-
<tr>
145
-
<td> 02</td>
146
-
<td> redeem</td>
147
-
<td>
148
-
Start the withdrawal process for a `value` of FXRP from the
149
-
Firelight type vault, registered with the `vaultId`, with the
150
-
`MasterAccountController` contract.
151
-
</td>
152
-
</tr>
153
-
<tr>
154
-
<td> 03</td>
155
-
<td> claimWithdraw</td>
156
-
<td>
157
-
Withdraw the `FXRP`, requested in the `value` period, from
158
-
Firelight type vault, registered with the `vaultId`, with the
|`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. |
135
+
|`01`|`deposit`| Deposit a `value` of FXRP into the Firelight type vault, registered with the `vaultId` with the `MasterAccountController` contract. |
136
+
|`02`|`redeem`| Start the withdrawal process for a `value` of vault shares (in drops) from the Firelight type vault, registered with the `vaultId`, with the `MasterAccountController` contract. |
137
+
|`03`|`claimWithdraw`| Withdraw the `FXRP`, requested in the `value` period, from Firelight type vault, registered with the `vaultId`, with the `MasterAccountController` contract. |
165
138
166
139
### Upshift
167
140
168
141
Instructions for interacting with an Upshift-type vault.
169
142
170
143
**Type ID:**`02`.
171
144
172
-
<table>
173
-
<thead>
174
-
<tr>
175
-
<td> **Command ID**</td>
176
-
<td>**Action** </td>
177
-
<td>**Description** </td>
178
-
</tr>
179
-
</thead>
180
-
<tr>
181
-
<td> 00</td>
182
-
<td> collateralReservationAndDeposit</td>
183
-
<td>
184
-
Reserve a `value` of lots of collateral in the agent vault,
185
-
registered with the `agentVaultId` with the `MasterAccountController`
186
-
contract. After successful minting, deposit the FXRP into the Upshift
187
-
type vault, registered with the `vaultId`, with the
188
-
`MasterAccountController` contract. Equivalent to sending a
189
-
`collateralReservation` instruction and a Upshift `deposit` instruction.
190
-
</td>
191
-
</tr>
192
-
<tbody>
193
-
<tr>
194
-
<td> 01</td>
195
-
<td> deposit</td>
196
-
<td>
197
-
Deposit a `value` of FXRP into the Upshift type vault,
198
-
registered with the `vaultId` with the `MasterAccountController`
199
-
contract.
200
-
</td>
201
-
</tr>
202
-
<tr>
203
-
<td> 02</td>
204
-
<td> requestRedeem</td>
205
-
<td>
206
-
Start the withdrawal process for a `value` of FXRP from the
207
-
Upshift type vault, registered with the `vaultId` with the
208
-
`MasterAccountController` contract.
209
-
</td>
210
-
</tr>
211
-
<tr>
212
-
<td> 03</td>
213
-
<td> claim</td>
214
-
<td>
215
-
Withdraw the `FXRP`, requested in the `value` period, from
216
-
Upshift type vault, registered with the `vaultId` with the
|`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. |
148
+
|`01`|`deposit`| Deposit a `value` of FXRP into the Upshift type vault, registered with the `vaultId` with the `MasterAccountController` contract. |
149
+
|`02`|`requestRedeem`| Start the withdrawal process for a `value` of vault shares (in drops) from the Upshift type vault, registered with the `vaultId` with the `MasterAccountController` contract. |
150
+
|`03`|`claim`| Withdraw the `FXRP` requested for the `value` date (encoded as `yyyymmdd`) from the Upshift type vault, registered with the `vaultId` with the `MasterAccountController` contract. |
151
+
223
152
</details>
224
153
225
-
## 2. Payment proof on Flare
154
+
## 2. Dispatch on Flare
155
+
156
+
### Proof-based flow
226
157
227
158
The operator monitors incoming transactions to the specified XRPL address.
228
-
Upon receiving a payment, it makes a [`Payment` attestation request](/fdc/attestation-types/payment) to the FDC.
229
-
The `Payment` proof and the user's XRPL address are passed to the `executeTransaction` function on the `MasterAccountController` smart contract on the Flare chain.
159
+
Upon receiving a payment, it requests a [`Payment` attestation](/fdc/attestation-types/payment) from the FDC and submits the proof together with the user's XRPL address to the appropriate facet on the `MasterAccountController`:
160
+
161
+
-[`reserveCollateral`](/smart-accounts/reference/IMasterAccountController#reservecollateral) — for command `00` of any instruction type.
162
+
Takes the payment reference and XRPL transaction id (no FDC proof needed at this stage, the user has only committed to mint).
163
+
-[`executeDepositAfterMinting`](/smart-accounts/reference/IMasterAccountController#executedepositafterminting) — second leg of the Firelight/Upshift collateral-reservation-and-deposit instructions, after FAssets minting completes.
164
+
-[`executeInstruction`](/smart-accounts/reference/IMasterAccountController#executeinstruction) — for all other reference-encoded instructions.
165
+
166
+
For the proof-bearing functions, the contract verifies the FDC proof and checks that:
230
167
231
-
The `MasterAccountController` contract first verifies the proof.
232
-
It then performs several checks on the proof:
168
+
- the receiving address matches the one configured for the operator,
169
+
- the source address matches the XRPL address passed to the function,
170
+
- the XRPL transaction id has not already been used (replay protection via `usedTransactionIds`).
233
171
234
-
- receiving address matches the one specified by the operator,
235
-
- the source address matches the XRPL address given to the function,
236
-
- that the proof has not yet been used for the same actions.
172
+
The contract then resolves the XRPL user's `PersonalAccount` from the address mapping, deploying it via `CREATE2` if it does not yet exist, and dispatches the instruction encoded in the payment reference.
237
173
238
-
Then, the `MasterAccountController` contract retrieves the XRPL user's smart account from a mapping.
239
-
If the account does not yet exist, it is created at this point.
174
+
### Direct-minting flow
240
175
241
-
The payment reference is decoded.
242
-
Depending on the value of the leading byte, a different function on the smart account is called.
176
+
When the user mints FXRP directly to their smart account via [FAssets direct minting](/fassets/direct-minting), the FAssets `AssetManager` calls back into [`mintedFAssets`](/smart-accounts/reference/IMasterAccountController#mintedfassets) on `MemoInstructionsFacet`.
177
+
The facet enforces that the caller is the `AssetManager`, resolves (or deploys) the user's `PersonalAccount`, pays an executor fee out of the minted FAssets, forwards the remainder to the personal account, and dispatches any memo instruction (`0xFF`, `0xE0`, `0xE1`, `0xE2`, `0xD0`, `0xD1`).
243
178
244
179
## 3. Actions on Flare
245
180
246
181
The XRPL user's smart account performs the actions in the instructions.
247
182
This can be any of the instructions listed above, reserving collateral for minting FXRP, transferring FXRP to another address, redeeming FXRP, depositing it into a vault ...
248
-
Furthermore, custom instructions can be executed - instructions for making any function call on Flare -, thought that requires an additional step for it to work (see the [Custom Instruction guide](/smart-accounts/3-custom-instruction.mdx))
183
+
Furthermore, custom instructions (`0xFF`) can be executed — arbitrary function calls on Flare, signed as an EIP-4337 `PackedUserOperation` and replayed on-chain by the personal account.
184
+
See the [Custom Instruction guide](/smart-accounts/custom-instruction) for the details.
0 commit comments