
Ask HN: Compile Rust to WebAssembly for EOS Smart Contract? - rayvy
So I&#x27;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.<p>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]).<p>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&#x27;m hoping I can just use my existing Rust knowledge, as opposed to having to learn C++)<p>[1] https:&#x2F;&#x2F;hackernoon.com&#x2F;compiling-rust-to-webassembly-guide-411066a69fde
======
steveklabnik
So, 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.

