Existing WASM to IC


I am thinking about a push-to-deploy module for ICME that would allow a user to spin up
an instance of an already existing WASM application, onto the IC.

What would one need to do, to get this WASM IC ready? What are the specs needed??
If it has a frontend does it need to work within Asset canister??


@domwoe @lastmjs


I think if the Wasm module targets another runtime (for example WASI) you’d need to somehow detect that and patch each system call to the equivalent on the IC.

1 Like

Wasm is just a code format. An application also expects an OS.

First, you’d need to know what environment and possible glue code that Wasm app targets, because that determines what imports it expects to be available.

Then you’d probably need to implement something more or less equivalent to a POSIX emulation layer on the IC. Or at least a sizeable portion thereof, like file system, I/O system, etc., which many applications may expect.

Finally, you’d need to figure out tooling to cram all that into a single Wasm module, since the IC does not yet support on-chain linking. That may be tough before Wasm officially supports multiple memories, which are a prerequisite for being able to merge multiple modules into one in general.

1 Like

But when we are building it with undefined-undefined it should be OS independent??
I know we can deploy single-wasm because I commonly deploy the ledger canister as wasm locally.

I am looking for specs that make a wasm like that ledger wasm work on the IC normally.

Actually I think this clears it up. Thanks!

Do you mean wasm32-unknown-unknown?

If so, you can still produce a Wasm module that will panic at runtime if certain things are called because they aren’t available. See: any limitation in using rust to develop ic? · Issue #123 · dfinity/cdk-rs · GitHub

If you’re interested in replacing I/O and filesystem access, you could try:

  • icfs provides implementations of std::io::{Read, Write, Seek} backed by stable memory to enable the use of existing Rust code that requires implementations of these traits.
  • icfs-fatfs uses icfs to leverage the fatfs crate in providing a FAT file system.
1 Like

I think the WASM I was looking into will not work because there are more than one working together. Started programming in Rust a bit because the transform function was out faster for the HTTP calls.

Fun to deep dive into how Rust compiles wasm32-unknown-unknown with Wasmtime. Anyway! NG on this usecase.