Help with Candid File construction

I found this project that is a web assembly compilation of javascript core. It only has a few functions that I think I can pull out of the c++(code at the main functions that I need. So I think I have the wasm and the js that I’d need to run the thing(basically it pushes a js string into the engine, executes it, and reads out the results with a couple of memory allocation functions along the way.). I think those are js_eval, stackAlloc, stackRestore, stackSave…maybe some others.

I understand that this is a terrible idea, and that running a js engine on top of wasm defeats the point of having a wasm engine…but I want to try it anyway just so that I can say that I can. There is a lot of js code out there and it might be interesting to push out canisters that do needed things without having to do a rewrite.

Anyway the function signatures look pretty simple…basically just char* and integers of various sizes, but I don’t really have any clue where to start with the candid files and what is/isn’t important to implement. Any suggestions? Anyone want to help me with it?

1 Like

To interoperate on the Internet Computer, the canister needs to understand the system API and the Candid serialization format. It cannot run an arbitrary Wasm module. To get started, I would recommend checking out the reverse example in C:

It contains the minimal bindings needed to reverse a string from a canister. Your Wasm module needs to somehow embed these APIs as well in order to run on the Internet Computer.

1 Like