Skip to content

Commit 5d1f575

Browse files
committed
add readme
1 parent 6bb130b commit 5d1f575

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

extism/readme.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# iroh + exsitm
2+
3+
This is an example of running iroh thorugh [exitsm](https://extism.org/) as a set of [host functions](https://extism.org/docs/concepts/host-functions). It's written entirely in rust, but the purpose is to show how one would build an API that any plugin could use to gain access to a plugin-host-provided iroh instance.
4+
5+
## Requirements
6+
7+
You'll need the latest version of the rust toolchain, and the `wasm32-unknown-unknown` target. Install it with:
8+
9+
```
10+
rustup target add wasm32-unknown-unknown
11+
```
12+
13+
## Running the Example
14+
15+
There are three
16+
17+
1. Build the WASM plugin
18+
2. Get a blob ticket
19+
3. run the host
20+
21+
### 1. Build the WASM plugin
22+
23+
`cd` to `extism/plugin` and run `cargo build --target wasm32-unknown-unknown`. If you get an error, check the requirements section above. This will generate a WASM plugin that actually calls the blob download host function.
24+
25+
### 2. Get a blob ticket
26+
27+
This example needs a `Raw` blob ticket, which you can get from `iroh blob add` on a raw file, or just use this one, which should be hosted on iroh.network:
28+
```
29+
blobabk62aofuwwwu5zb5ocvzj5v3rtqt6siglyuhoxhqtu4fxravvoteajcnb2hi4dthixs65ltmuys2mjomrsxe4bonfzg62bonzsxi53pojvs4lydaac2cyt22erablaraaa5ciqbfiaqj7ya6cbpuaaaaaaaaaaaahjceagucztuhgez4qucv2733xphmgpc2nkgj54od2vuygn6sz4zzxo6ce
30+
```
31+
(it's a text file that says hello)
32+
33+
### 3. Run the host
34+
35+
The host code will actually call the example. `cd` to `./extism/host` and run
36+
37+
```
38+
cargo run <TICKET>
39+
```
40+
41+
pasting in the ticket you'd like to fetch. It'll fetch the bytes & print it out, proving this host can provide iroh to extism plugins!
42+
43+
44+
## Future work
45+
46+
What would be truly neat would be to reverse the direction, and write a plugin that brings iroh to a host. For that we'd need to be able to compile some/all of iroh to WASM, which we're [working on](https://github.com/n0-computer/iroh/issues/1803).

0 commit comments

Comments
 (0)