Skip to content

Commit f8ebc27

Browse files
authored
Hackathon updates (#925)
2 parents 893b444 + a1d38bb commit f8ebc27

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ Only function calls with specific parameter values included can be registered.
8080
That means that a new custom instruction needs to be registered for each unique action (though this can be done just seconds in advance).
8181
It is also the reason why special FAsset actions have their own IDs, instead of defaulting to the custom call - it allows us to also specify certain parameters within the instructions on XRPL.
8282

83+
:::warning
84+
Encoding calldata by hand is error prone.
85+
It is recommended to use established libraries, or an [online tool](https://abi.hashex.org/) (if you want to quickly check something).
86+
:::
87+
8388
## Call hash
8489

8590
To produce the custom instructions calldata, we first ABI encode the array of the `IMasterAccountController.CustomInstruction` struct.

docs/smart-accounts/guides/01-fsa-cli.mdx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ That number of lots of FXRP are burned from the user's smart account, and the sa
8989
### `mint`
9090

9191
Mints a number of `lots` of FXRP to the user's smart account.
92-
The script first reserves collateral with the agent with the `address`, by sending a `reserveCollateral` instruction.
92+
The script first reserves collateral with the agent with the `address` (if you are unsure what agent to choose on coston2, use `0x55c815260cBE6c45Fe5bFe5FF32E3C7D746f14dC`), by sending a `reserveCollateral` instruction.
9393
It then sends a `lots` amount of XRP to the agent's underlying address.
9494
An executor, determined by the `MasterAccountController`, will complete the minting process, and `lots` of FXRP will be minted to the user's smart account.
9595

@@ -114,7 +114,7 @@ Make a transaction to the `address`, paying the `value`, and attaching the `call
114114
The `calldata` is the encoding of a function and its argument values, on the smart contract at the `address.
115115

116116
```sh
117-
./smart_accounts.py bridge deposit -a <address> -v <value> -d <calldata>
117+
./smart_accounts.py bridge custom -a <address> -v <value> -d <calldata>
118118
```
119119

120120
Before making a transaction on XRPL with the necessary instructions, this command performs an additional step.
@@ -123,6 +123,13 @@ Then, it calls the `registerCustomInstruction` function of the `MasterAccountCon
123123

124124
Thus, it both registers a custom instruction with the `MasterAccountController` contract and retrieves the required `callHash`, which it can then send to the operator's XRPL address as instructions.
125125

126+
You can also use the command with json file containing an array of custom instructions.
127+
Two provided json files in `json_examples/` directory demonstrate the expected format.
128+
129+
```sh
130+
./smart_accounts.py bridge custom json_example/sendFXRPCoston.json
131+
```
132+
126133
## `debug` command
127134

128135
The `debug` command offers some utility options for running the CLI.
@@ -141,6 +148,12 @@ The `seed` is a string representing an XRPL account.
141148
./smart_accounts.py debug mock-custom -s <seed> -a <address> -v <value> -d <calldata>
142149
```
143150

151+
As with the `custom` command, you can also use a json file containing an array of custom instructions.
152+
153+
```sh
154+
./smart_accounts.py debug mock-custom -s <seed> json_example/sendFXRPCoston.json
155+
```
156+
144157
### `check-status`
145158

146159
Check the status of the XRPL transaction with the `xrpl_hash`.
@@ -168,3 +181,12 @@ This is equivalent to running the following commands:
168181
./smart_accounts.py bridge claim-withdraw
169182
./smart_accounts.py bridge redeem -l <mint>
170183
```
184+
185+
## `encode` command
186+
187+
The `encode` command prints encoded memo fields that can be used in XRPL transactions to instruct the operator to perform certain actions on Flare.
188+
189+
```sh
190+
./smart_accounts.py encode custom json_example/requestRedemption.json
191+
./smart_accounts.py encode mint -l 1
192+
```

docs/smart-accounts/guides/02-custom-instructions.mdx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ We want to send `1 FLR` to the contract, and save it under number `42`.
8080
The address of the `Foo` contract is `0x296432C15504Ed465fAce11E54Ce4aac50cCd8A3`.
8181
Using an online ABI-encoding tool, we get that the following hash for the `bar` function, with `42` as input: `0x0423a132000000000000000000000000000000000000000000000000000000000000002a`.
8282

83+
:::warning
84+
Encoding calldata by hand is error prone.
85+
It is recommended to use established libraries, or an [online tool](https://abi.hashex.org/) (if you want to quickly check something).
86+
:::
87+
8388
There are two ways we can go about developing the custom instructions.
8489
We will start with an approach, which is what the production code would take.
8590
Afterwards, we will use the the mock functions to speed up the development.
@@ -97,14 +102,14 @@ It is necessary to send some instructions, because that is what creates an accou
97102
We then need to retrieve the smart account address.
98103

99104
```sh
100-
./smart_accounts personal-account --from-env print
105+
./smart_accounts.py personal-account --from-env print
101106
```
102107

103108
With the address, we can go to the [Flare faucet](https://faucet.flare.network/coston2) and request C2FLR for the smart account address.
104109
We can also do this through the CLI.
105110

106111
```sh
107-
./smart_accounts personal-account --from-env faucet
112+
./smart_accounts.py personal-account --from-env faucet
108113
```
109114

110115
Afterwards, we can run the following command again.
@@ -121,12 +126,18 @@ First, we need to create a mock account, which we do with the command.
121126
This will only work if our Flare address has sufficient funds.
122127

123128
```sh
124-
./smart_accounts mock-create-fund --seed "mockAccount" --value 1
129+
./smart_accounts.py debug mock-create-fund --seed "mockAccount" --value 1
125130
```
126131

127132
Here we arbitrarily chose the name `mockAccount` as the account address.
128133
Behind the scenes, the string `mockAccount` will be concatenated with our Flare address.
129134

135+
You can check the associated account with the command:
136+
137+
```sh
138+
./smart_accounts.py debug mock-print -s <seed>
139+
```
140+
130141
Then, we execute the custom instructions.
131142
We use the string `mockAccount` as the seed.
132143

0 commit comments

Comments
 (0)