Skip to content

Commit

Permalink
make requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoGiachetta committed Sep 5, 2024
1 parent d249eb6 commit 3166484
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions examples/wasm-demo-cairo1/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Demo of `cairo-vm` on WebAssembly

While cairo-vm is compatible with WebAssembly, it doesn't implement any bindings to it.
Instead, create a new WebAssembly crate with cairo-vm as a dependency and implement the required functionality there.
Instead, create a new WebAssembly crate with cairo-vm and cairo1-run as dependencies and implement the required functionality there.

Since mimalloc is not automatically compilable to WebAssembly, the cairo-vm dependency should disable the default features, which will in turn disable mimalloc.

Expand All @@ -11,7 +11,7 @@ A working example is provided in this repository.

To compile and run the example you need:

- a Cairo 0 compiler
- an either Cairo 1 or Cairo 2 compiler
- the _wasm-pack_ crate
- some HTTP server (for example: the `live-server` npm module)

Expand All @@ -20,12 +20,20 @@ To compile and run the example you need:
## Building

To build the example, first compile your Cairo 1.x program:
To build the example, first compile your Cairo 1 / 2 program:

Cairo 1

```sh
../../cairo1/bin/cairo-compile -r ./bitwise.cairo bitwise.sierra
```

Cairo 2

```sh
../../cairo2/bin/cairo-compile -r ./bitwise.cairo bitwise.sierra
```

> It's important to use the `-r` flag. If not, the `main` function won't be recognized.
And then the WebAssembly package:
Expand All @@ -42,7 +50,7 @@ To run the example webpage, you need to run an HTTP server.
For example, using the _live-server_ npm module:

```sh
# while in <repo>/examples/wasm-demo
# while in <repo>/examples/wasm-demo-cairo1
npx live-server
```

Expand Down

0 comments on commit 3166484

Please sign in to comment.