Skip to content

Commit f5bb863

Browse files
committed
docs/rofl/features/appd: Add Queries and ROFL clients
1 parent 394da33 commit f5bb863

File tree

1 file changed

+76
-7
lines changed

1 file changed

+76
-7
lines changed

docs/rofl/features/appd.md

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,18 @@ services:
1515
- /run/rofl-appd.sock:/run/rofl-appd.sock
1616
```
1717
18-
The following sections describe the available endpoints.
18+
## ROFL clients
19+
20+
After binding the UNIX socket above, we strongly suggest to access the ROFL
21+
REST API through one of the ROFL clients for your favorite language:
22+
23+
- `oasis-rofl-client` for [Python]
24+
- `@oasisprotocol/rofl-client` for [TypeScript]
25+
- `oasis-rofl-client` for [Rust]
26+
27+
If you can't find the desired language above, please reach out to us on our
28+
[#dev-central Discord channel][discord]. In the meantime use a generic HTTP
29+
client and connect to the endpoints described next as follows.
1930

2031
:::info UNIX sockets and HTTP headers
2132

@@ -26,9 +37,15 @@ format.
2637

2738
:::
2839

40+
[Python]: https://pypi.org/project/oasis-rofl-client/
41+
[TypeScript]: https://www.npmjs.com/package/@oasisprotocol/rofl-client
42+
[Rust]: https://github.com/oasisprotocol/oasis-sdk/tree/main/rofl-client/rs
2943
[compose-volumes]: https://docs.docker.com/reference/compose-file/services/#short-syntax-5
44+
[discord]: https://oasis.io/discord
45+
46+
## Endpoints
3047

31-
## App Identifier
48+
### App Identifier
3249

3350
This endpoint can be used to retrieve the app ID.
3451

@@ -40,7 +57,7 @@ This endpoint can be used to retrieve the app ID.
4057
rofl1qqn9xndja7e2pnxhttktmecvwzz0yqwxsquqyxdf
4158
```
4259
43-
## Key Generation
60+
### Key Generation
4461
4562
Each registered app automatically gets access to a decentralized on-chain key
4663
management system.
@@ -83,7 +100,7 @@ state is erased.
83100

84101
The generated `key` is returned as a hexadecimal string.
85102

86-
## Authenticated Transaction Submission
103+
### Authenticated Transaction Submission
87104

88105
An app running in ROFL can also submit _authenticated transactions_ to the chain
89106
where it is registered at. The special feature of these transactions is that
@@ -177,13 +194,13 @@ For example:
177194

178195
[call result]: https://api.docs.oasis.io/rust/oasis_runtime_sdk/types/transaction/enum.CallResult.html
179196

180-
## Replica Metadata
197+
### Replica Metadata
181198

182199
Replica metadata allows apps to publish arbitrary key-value pairs that are
183200
included in the on-chain ROFL replica registration. This metadata is
184201
automatically namespaced with `net.oasis.app.` when published on-chain.
185202

186-
### Get Metadata
203+
#### Get Metadata
187204

188205
Retrieve all user-set metadata key-value pairs.
189206

@@ -198,7 +215,7 @@ Retrieve all user-set metadata key-value pairs.
198215
}
199216
```
200217

201-
### Set Metadata
218+
#### Set Metadata
202219

203220
Set metadata key-value pairs. This replaces all existing app-provided metadata
204221
and will trigger a registration refresh if the metadata has changed.
@@ -216,3 +233,55 @@ and will trigger a registration refresh if the metadata has changed.
216233

217234
**Note:** Metadata is validated against runtime-configured limits for the
218235
number of pairs, key size, and value size.
236+
237+
### Queries
238+
239+
Runs arbitrary query method defined in the [Oasis Runtime SDK] module and
240+
returns the result.
241+
242+
**Endpoint:** `/rofl/v1/query` (`POST`)
243+
244+
**Example request:**
245+
246+
```json
247+
{
248+
"method": "rofl.App",
249+
"args": "a16269645500694cb01f85408d624ea267f657bf285787a61db3"
250+
}
251+
```
252+
253+
Above we called the [`rofl.App`] method and passed the ROFL app ID
254+
`rofl1qrl7nqwvaledwkw3n75jd7htklvsczje554u4p6k` (`a1` (map) + `626964` (key
255+
"id") + `55` (byte string, 21 bytes) + app ID).
256+
257+
[`rofl.App`]: https://github.com/oasisprotocol/oasis-sdk/blob/394da333625a189abd8b752a9f2dc46bb883a781/runtime-sdk/src/modules/rofl/mod.rs#L647
258+
[special branch]: https://github.com/oasisprotocol/demo-rofl/blob/5ffce78b2c2cf606f9bf1950ea02804b72ba3b84/docker/app.sh#L9-L18
259+
[ROFL-8004 implementation]: https://github.com/oasisprotocol/erc-8004/blob/18f8630f7397ec889ea55b008391664f3b736128/rofl-8004/rofl_metadata.py#L47
260+
261+
**Request fields:**
262+
263+
- `method`: The internal name of the method. Query methods are defined with
264+
the `#[handler(query = "...")]` annotation in the [Oasis Runtime SDK] source.
265+
- `args`: CBOR-serialized and hex-formatted parameters specific for that method.
266+
267+
[Oasis Runtime SDK]: https://github.com/oasisprotocol/oasis-sdk/tree/main/runtime-sdk
268+
269+
**Example response:**
270+
271+
```json
272+
{"data":"a76269645500ffe981cceff2d759d19fa926faebb7d90c0a59a56373656b582056c6d4841fa5ad24ad761088cb7053ad312ef13f3c2f405640fdba2bde4c14386561646d696e55007814f3d954f41b6459eb9e4bc8fbc6767ece5aa9657374616b658249056bc75e2d631000004066706f6c696379a56466656573026671756f746573a263696173f663706373a363746478a173616c6c6f7765645f7464785f6d6f64756c657380737463625f76616c69646974795f706572696f64181e781e6d696e5f7463625f6576616c756174696f6e5f646174615f6e756d6265721268656e636c6176657382a2696d725f7369676e6572582000000000000000000000000000000000000000000000000000000000000000006a6d725f656e636c6176655820bd4844a79a12ba365e890ddeaebbc4e4292797c7d956b42c2e25e4aefce3b124a2696d725f7369676e6572582000000000000000000000000000000000000000000000000000000000000000006a6d725f656e636c6176655820412c94a9baa0949f718dbba41ab89c38ea5c320345bba36b07e2ef857ffe2fb96c656e646f7273656d656e747381a163616e79a06e6d61785f65787069726174696f6e036773656372657473a26a50494e4154415f4a5754590327a462706b58207f88546291174f854a8ce2eb4bbfc8e62e40d60cdae2d600920a766d3006bf6c646e616d65581aad0460d0f742ad697b6d7c8462cc2b153deeb051a791553ef52b656e6f6e63654f8cbbe6631910d9a702e49bd30ee8f46576616c75655902c1352d823e54f75c846579066e2c1a750387f0630e3f29dba5524984712883bb33371ff017e507ae432b135312af64bfb85f3b17def05b2ac2744256f5accf1a26b29cd8cd412f08bfc9204f9bfa670b2d65972cfc4a8d4e2074402f21c18dfe554b1f0a8a731c077699f741807b3a4047ef4dc570958b8b46111a445259e93c9b92a5f72a23d32cbbef875efe586a8ddda38f1fa286d19b369a2022c3eae1cdbf6f6de4dc055bbab36a2c4830f8e2c64437f5f878f419e21f3a4c0f13c47b63697668b34722eaa61bdffa12e82be6d0266a41590254c9d70e9237475f6115c2867065c49afa8032acdfe0bc5dc671ef48ebc58d893937659243479e2eaa38815cd8665541e4c7e40349524cda15f2d410cba100ee27f0a59dc63534f7cff2444b57c7b74060cf8c3e21e1590b597384a89a463d6bb4a52fc52a4592889448a8f8e0c02fef1689c1efea58ddc08783f6d22d7a908cdf2a45bc46a79a3b73ff5f13bbbf7219973a7382eee84b3b4d48036b5e87fb24223e6387a3e37f9c1ac9722534adfef0201ec13db2e70fe9cd0336f020e50b59d7d32951378f568a4ef3a8117386ff0f1ba4b7d33dcf913daa696a6a7d64d20220b0e5eec994ea56aa9c01f56f5e12bf7d555b3f4a218ddbd8ae1586d5cb1e76802c90e26472b233686e8449284829378163acd77d1b65d4953a76cc497584580c1a5ac4fe6d97fd818fa53c2eb43c6f1b7a79211ef57f24036b1f8ed37f4c3d36873bbbd876769a5fde17add6926317afc96c9707e10b150735c63877ffd6475b1a27b6dd108940f0097375e422b1d308c6c8a0a83847368f5760778c54f2a70b44f9365c55c4b5d69341cad62d6fdb11aa25a9e26b4977adebd65718042bda1cbbf988298d293547107c2f5899352188179bc4d22febc66e8e351885498e707dee583d052c0b7c13f930e4529b59c36c20ee3ee6d29d1a3e2bb65bd489b7206cd45d2ae046f1e147d6407c166e494e465552415f4150495f4b45595899a462706b582074be2e227be81a5e35943ac1b79e238395b9bc367f7a0d1eed740c259ae23a37646e616d65581ee5190cda87688753f6f221890bfed8fe0e27b3ced4a9bc54537da1f4cd90656e6f6e63654fcf5411193abf4f4711f17179ea4b6f6576616c756558304675a29c8398bc94b5057063b4badeb9937a6e019ef7f8095d6b5a035106d4e8e7d710af9b6883848886481c1d180cbc686d65746164617461a7736e65742e6f617369732e726f666c2e6e616d656f76616c696461746f722d6167656e74756e65742e6f617369732e726f666c2e617574686f72782a4d61746576c5be204a656b6f766563203c6d617465767a406f6173697370726f746f636f6c2e6f72673e766e65742e6f617369732e726f666c2e6c6963656e73656a4170616368652d322e30766e65742e6f617369732e726f666c2e76657273696f6e65302e312e30776e65742e6f617369732e726f666c2e686f6d6570616765784f68747470733a2f2f6769746875622e636f6d2f6f6173697370726f746f636f6c2f6572632d383030342f626c6f622f6d61737465722f524541444d452e6d642376616c696461746f722d6167656e7478196e65742e6f617369732e726f666c2e7265706f7369746f7279782968747470733a2f2f6769746875622e636f6d2f6f6173697370726f746f636f6c2f6572632d38303034781a6e65742e6f617369732e726f666c2e6465736372697074696f6e787f4c697374656e7320746f2056616c69646174696f6e52657175657374206576656e7473206f6620746865204552432d383030342076616c69646174696f6e20726567697374727920616e642076616c696461746573207768657468657220746865206167656e7420697320706f776572656420627920524f464c205445452e"}
273+
```
274+
275+
Inside `data` the JSON response contains the CBOR-serialized method's return
276+
value in hex format.
277+
278+
:::example
279+
280+
Check out this [special branch] of the ROFL demo repository for calling queries
281+
directly with `curl`.
282+
283+
For the production-ready Python example, check out the [ROFL-8004
284+
implementation] where the query endpoint is used to fetch various app metadata
285+
for registration in the ERC-8004 identity registry.
286+
287+
:::

0 commit comments

Comments
 (0)