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).

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++)

UPDATE (post-accepted answer): Info from a similar HackerNews thread, answered by a member of the Rust core team:

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.

Thread can be found here

wasm-bindgen crate here

1 Answer 1


While executing the contracts in the VM, it doesn't really matter what was the source language: be it C++ or Rust. It only cares about the compiled WASM being accepted by the WASM interpreter.

Yes, you can write Rust, but because there's no explicit support or work done towards supporting Rust, you'll probably need quite a bit of tweaking. Several months ago, someone wrote an article here where they showed that the WAST generated from Rust was very similar to the one generated from C++.

For reference, this is their rs contract:

extern "C" {
    fn printi(c: u64);
pub extern "C" fn init() {
    unsafe { printi(5); }
pub extern "C" fn apply(_: u64, _: u64) {}
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} }

Note, however, that this was using an older version of EOSIO and an older version of Rust, so it's just pasted as an example.

So, yes, you can do it, but there's gonna be some overhead and not much documentation in the current state. Also, given that EOSIO is written in C++, you may still need to learn at least some C++ at least until the tooling is available.

Will there be any official support?

It used to be in the official roadmap from BlockOne to support Rust by Spring 2018:

Adding support for additional langauges to be compiled to WASM: C++, Rust, etc.

However, I believe this was dropped as I don't see anyone working on it in the eosio repos, and, in the official docs, it says as follows:

Other toolchains in development by 3rd parties include: Rust, Python, and Solidity. While these other languages may appear simpler, their performance will likely impact the scale of application you can build. We expect that C++ will be the best language for developing high-performance and secure smart contracts and plan to use C++ for the foreseeable future.

  • Answered accepted. @ confused00 not sure how familiar you are with EOS (I'm familiar with the link you provided), but do you know if there's any active roadmap to build support for any other language than Cpp ? Commented Sep 4, 2018 at 20:33
  • 2
    @ralston edited my answer to add what I know about the status of official support for other languages (basically, no official plans at the moment)
    – confused00
    Commented Sep 4, 2018 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.