Skip to content

Commit e1405d4

Browse files
feat(docs): add hash custom instruction guides
1 parent 6591206 commit e1405d4

10 files changed

Lines changed: 858 additions & 37 deletions

File tree

docs/smart-accounts/1-overview.mdx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Flare Smart Accounts support two complementary flows for turning an XRPL `Paymen
3333
### Proof-based flow (payment reference)
3434

3535
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`.
36+
2. The operator requests a [`Payment` attestation](/fdc/attestation-types/payment) from the [Flare Data Connector (FDC)](/fdc/overview) and submits it to the `MasterAccountController`.
3737
3. The XRPL user's `PersonalAccount` performs the action encoded in the reference.
3838

3939
<ThemedImage
@@ -51,8 +51,8 @@ Flare Smart Accounts support two complementary flows for turning an XRPL `Paymen
5151

5252
### Direct-minting (memo) flow
5353

54-
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`.
54+
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-comparison) carrying the instruction.
55+
2. The FAssets `AssetManager` mints FXRP to the `MasterAccountController` and calls back into [`handleMintedFAssets`](/smart-accounts/reference/IMasterAccountController#handlemintedfassets) on `MemoInstructionsFacet`.
5656
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).
5757

5858
```mermaid
@@ -65,16 +65,16 @@ graph TB
6565
subgraph Flare["Flare"]
6666
Executor[("<b>Executor</b><br/><i>backend</i>")]
6767
AssetManager["<b>FAssets AssetManager</b><br/><i>contract</i>"]
68-
MAC["<b>MasterAccountController</b><br/><i>contract</i>"]
69-
PA["<b>PersonalAccount</b><br/><i>contract</i>"]
68+
MasterAccountController["<b>MasterAccountController</b><br/><i>contract</i>"]
69+
PersonalAccount["<b>PersonalAccount</b><br/><i>contract</i>"]
7070
end
7171
7272
User -- "1 - Payment + memo" --> Agent
7373
Agent -. "2 - observe payment" .-> Executor
7474
Executor -- "3 - executeDirectMinting" --> AssetManager
75-
AssetManager == "4 - mint FXRP +<br/>mintedFAssets callback" ==> MAC
76-
MAC -- "5 - forward FXRP +<br/>dispatch memo instruction" --> PA
77-
User -. "controls" .-> PA
75+
AssetManager == "4 - mint FXRP +<br/>handleMintedFAssets callback" ==> MasterAccountController
76+
MasterAccountController -- "5 - forward FXRP +<br/>dispatch memo instruction" --> PersonalAccount
77+
User -. "controls" .-> PersonalAccount
7878
7979
style Flare stroke-dasharray: 5 5
8080
style XRPL stroke-dasharray: 5 5
@@ -83,7 +83,7 @@ graph TB
8383
<p style={{ textAlign: "center", fontStyle: "italic" }}>
8484
Direct-minting flow: XRPL `Payment` carrying a memo (1) → FAssets agent (2) →
8585
executor calls `AssetManager.executeDirectMinting` (3) → `AssetManager` mints
86-
FXRP and calls back into `mintedFAssets` (4) → `MasterAccountController`
86+
FXRP and calls back into `handleMintedFAssets` (4) → `MasterAccountController`
8787
forwards FXRP and dispatches the memo to the user's `PersonalAccount` (5).
8888
</p>
8989

@@ -106,7 +106,7 @@ The first nibble is the instruction type.
106106
This is either `FXRP`, `Firelight`, or `Upshift` (with corresponding type IDS `0`, `1`, and `2`).
107107
The second nibble is the instruction command; the available commands are different for each instruction type.
108108

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.
109+
For the direct-minting flow, the memo carries a different layout — see the [Full Custom Instruction guide](/smart-accounts/full-custom-instruction) for the `PackedUserOperation` format, the [Hash Custom Instruction guide](/smart-accounts/hash-custom-instruction) for the 0xFE variant, or the [comparison](/smart-accounts/custom-instruction-comparison) of `0xFF`/`0xFE` and the executor-management codes `0xE0`/`0xE1`/`0xE2`/`0xD0`/`0xD1`.
110110

111111
<details>
112112
<summary>Table of instruction IDs and corresponding actions.</summary>
@@ -173,16 +173,17 @@ The contract then resolves the XRPL user's `PersonalAccount` from the address ma
173173

174174
### Direct-minting flow
175175

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`).
176+
When the user mints FXRP directly to their smart account via [FAssets direct minting](/fassets/direct-minting), the FAssets `AssetManager` calls back into [`handleMintedFAssets`](/smart-accounts/reference/IMasterAccountController#handlemintedfassets) 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`, `0xFE`, `0xE0`, `0xE1`, `0xE2`, `0xD0`, `0xD1`).
178178

179179
## Actions on Flare
180180

181181
The XRPL user's smart account performs the actions in the instructions.
182182
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 ...
183-
Furthermore, custom instructions (`0xFF`) can be executed — arbitrary function calls on Flare, encoded as an EIP-4337 `PackedUserOperation` carried in the XRPL memo and replayed on-chain by the personal account.
183+
Furthermore, custom instructions can be executed — arbitrary function calls on Flare, encoded as an EIP-4337 `PackedUserOperation` and replayed on-chain by the personal account.
184+
The user operation can be carried in the XRPL memo in full (opcode `0xFF`, see the [Full Custom Instruction guide](/smart-accounts/full-custom-instruction)), or committed to as a 32-byte hash with the bytes delivered to Flare by an off-chain executor (opcode `0xFE`, see the [Hash Custom Instruction guide](/smart-accounts/hash-custom-instruction)).
184185
Authorization comes from the XRPL `Payment` signature itself; the on-chain check only validates the `sender` and `nonce` fields of the `PackedUserOperation`.
185-
See the [Custom Instruction guide](/smart-accounts/custom-instruction) for the details.
186+
The [Custom Instruction Comparison](/smart-accounts/custom-instruction-comparison) covers when to pick each.
186187

187188
## Video Tutorials
188189

docs/smart-accounts/3-full-custom-instruction.mdx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,16 @@ A destination tag forces [FAssets direct minting](/fassets/direct-minting) to cr
3535

3636
The XRPL memo carries a 10-byte instruction header followed by the ABI-encoded `PackedUserOperation`:
3737

38-
| Bytes | Field | Meaning |
39-
| ----- | ---------------- | ------------------------------------------------------------------------ |
40-
| `0` | `instructionId` | `0xFF` — full custom instruction |
41-
| `1` | `walletId` | One-byte wallet identifier assigned by Flare; `0` if not registered |
42-
| `2-9` | `executorFeeUBA` | Executor fee in the FAsset's smallest unit, big-endian `uint64` |
43-
| `10+` | `userOpData` | `abi.encode(PackedUserOperation)` — the call payload the facet decodes |
38+
| Bytes | Field | Meaning |
39+
| ----- | ---------------- | ---------------------------------------------------------------------- |
40+
| `0` | `instructionId` | `0xFF` — full custom instruction |
41+
| `1` | `walletId` | One-byte wallet identifier assigned by Flare; `0` if not registered |
42+
| `2-9` | `executorFeeUBA` | Executor fee in the FAsset's smallest unit, big-endian `uint64` |
43+
| `10+` | `userOpData` | `abi.encode(PackedUserOperation)` — the call payload the facet decodes |
4444

4545
The total memo length is `10 + len(abi.encode(userOp))` bytes.
46-
The XRPL caps each memo at roughly `1024` bytes, so large or repetitive call batches may need to be split across multiple XRPL payments.
46+
The XRPL caps each memo at `1024` bytes, so large or repetitive call batches must be split across multiple XRPL payments — each of which pays its own FAssets minting fee and executor fee — and a single call whose ABI-encoded calldata alone exceeds the budget cannot be expressed at all without deploying a shim contract on Flare to compress it.
47+
The [Hash Custom Instruction](/smart-accounts/hash-custom-instruction) was added specifically to lift this cap: its memo is a constant 42 bytes regardless of batch size.
4748

4849
## User operation payload
4950

0 commit comments

Comments
 (0)