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
@@ -24,8 +23,9 @@ Flare Smart Accounts allow users to execute custom function calls on the Flare c
24
23
The process expands on the workflow for other actions by including an additional step at the beginning.
25
24
26
25
In order for the `MasterAccountController` contract to be able to give a custom instruction to a personal account, the custom action must first be registered with the said contract.
27
-
The custom instruction is stored in a mapper, with its 31-byte hash as a key.
28
-
That hash is then sent as the payment reference, along with the byte representation of the number 99 in the first byte.
26
+
The custom instruction is stored in a mapper, with its 30-byte hash as a key.
27
+
That hash is then sent as the payment reference, along with the byte representation of the hexadecimal number `ff` (decimal `255`) in the first byte and the `walletId` in the second byte.
28
+
The `walletId` is a Flare-designated value, used by the operator for wallet identification.
29
29
30
30
<div
31
31
style={{
@@ -39,8 +39,12 @@ That hash is then sent as the payment reference, along with the byte representat
39
39
alt="Breakdown of bytes in payment reference for the custom action"
@@ -57,17 +61,16 @@ We expand the workflow described in the [Flare Smart Accounts overview](/smart-a
57
61
58
62
## Custom Instructions
59
63
60
-
Custom instructions are an array of the `IMasterAccountController.CustomInstruction` Solidity struct.
64
+
Custom instructions are an array of the `CustomInstructions.CustomCall` Solidity struct.
61
65
The struct contains three fields:
62
66
63
-
-**targetContract**: the address of the smart contract that will execute the custom function
64
-
-**value**: the amount of FLR paid to the contract
65
-
-**data**: transaction calldata, which includes a function selector and values of the function's arguments
67
+
-`targetContract`: the address of the smart contract that will execute the custom function
68
+
-`value`: the amount of FLR paid to the contract
69
+
-`data`: transaction calldata, which includes a function selector and values of the function's arguments
66
70
67
71
Each of the custom instructions in the array will be performed in order.
68
72
A call to the `targetContract` address is made, with the specified `value` and the calldata `data`.
69
73
70
-
{/* TODO:(Nik) explain how calldata is produced */}
71
74
In Solidity, we can obtain the calldata by doing the following:
72
75
73
76
```Solidity
@@ -87,26 +90,45 @@ It is recommended to use established libraries, or an [online tool](https://abi.
87
90
88
91
## Call hash
89
92
90
-
To produce the custom instructions calldata, we first ABI encode the array of the `IMasterAccountController.CustomInstruction` struct.
91
-
We then take the `keccak256` hash of that value, and drop the last byte.
93
+
To produce the custom instructions calldata, we first ABI encode the array of the `CustomInstructions.CustomCall` struct.
94
+
We then take the `keccak256` hash of that value, and drop the first two bytes (`(1 << 240) - 1` shifts the number binary number `1` left `30*8` times, and replaces it with `0` and all the `0`s that follow it with `1`; essentially, we create a mask of length `30*8` of only `1`s).
92
95
That is the call hash that is provided as the payment reference for the custom action, and the ID under which the custom instructions are stored in the `MasterAccountController` contract.
We register a custom instruction by calling the `registerCustomInstruction` function on the `MasterAccountController` contract.
111
-
The `IMasterAccountController.CustomInstruction` array is provided as an argument.
128
+
The `CustomInstructions.CustomCall` array is provided as an argument.
112
129
It is encoded as described above and stored in a `CustomInstructions` mapping.
130
+
131
+
To obtain the instruction that can be sent as the memo of an XRPL Payment transaction, we take the call hash produced by the `encodeCustomInstruction` function and modify it the following way.
132
+
First, we remove the initial two bytes from this hash.
133
+
Next, we prepend the hexadecimal value `ff` followed by the `walletId`.
In this guide we will take a look at how we can use the [Flare smart accounts CLI](/smart-accounts/guides/fsa-cli) to perform a mint action, followed by the transfer of freshly minted FXRP.
20
+
In this guide we will take a look at how we can use the [Flare smart accounts CLI](/smart-accounts/guides/cli/introduction) to perform a mint action, followed by the transfer of freshly minted FXRP.
21
21
What this allows us to do is to, effectively, **mint FXRP onto someone else's Flare address**.
22
22
This guide is aimed primarily at Web3 developers who desire to engage with the FAssets system but want to sidestep the base minting process.
0 commit comments