3 ms·
Ask HN: Compile Rust to WebAssembly for EOS Smart Contract?
So I'm familiar with the fact that the supported language for EOS smart contracts is C++. However, the EOS docs mention that even the C++ needs to compile down to WebAssembly.
So my question is, could I write my EOS smart contract in Rust, and use a crate to compile my Rust into Web Assembly? (A very loose example of compiling Rust to WebAssembly can be found here[1]).
Or is a C++ compiled .wasm file significantly different from a Rust compiled .wasm file? (I really want to write EOS smart contracts, but I'm hoping I can just use my existing Rust knowledge, as opposed to having to learn C++)
[1] https://hackernoon.com/compiling-rust-to-webassembly-guide-411066a69fde
- steveklabnik 8y agoSo, a .wasm file can call into functions defined by its host environment; this is often a browser but in your case, it’s the EOS VM. The trick is letting Rust know what those functions are so you can call them. wasm-bindgen should have you covered there. Beyond that, it’s all the same; the VM can’t care what the original language is.