TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Compile Rust to WebAssembly for EOS Smart Contract?

2 点作者 rayvy超过 6 年前
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

1 comment

steveklabnik超过 6 年前
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.<p>Beyond that, it’s all the same; the VM can’t care what the original language is.