Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rvanasa/motoko-rust-starter
Motoko + Rust starter project (Wasm component model)
https://github.com/rvanasa/motoko-rust-starter
Last synced: about 2 months ago
JSON representation
Motoko + Rust starter project (Wasm component model)
- Host: GitHub
- URL: https://github.com/rvanasa/motoko-rust-starter
- Owner: rvanasa
- Created: 2024-07-08T16:36:36.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-07-11T19:23:37.000Z (6 months ago)
- Last Synced: 2024-07-11T23:48:35.147Z (6 months ago)
- Language: Shell
- Size: 33.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Motoko + Rust Starter
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/rvanasa/motoko-rust-starter)
> Note: running in-browser currently takes a while due to building the Motoko compiler from source.
## 📦 Overview
This repository is a minimal starter project for calling Rust functions from a Motoko program using the [WebAssembly Component Model](https://component-model.bytecodealliance.org/). While this is currently intended to be used with [Wasmtime](https://github.com/bytecodealliance/wasmtime#readme), it's possible to run the generated Motoko + Rust component in any environment with component model support.
It's currently possible to call a function with a `Blob` input and return value, which can be used to pass arbitrary Candid-encoded values.
## ⚙️ Getting Started
### System Requirements
* Unix operating system (tested on Ubuntu and macOS)
* [Rust](https://www.rust-lang.org/)
* [Wasmtime](https://github.com/bytecodealliance/wasmtime#readme)
* [`wasm-tools`](https://github.com/bytecodealliance/wasm-tools#readme)
* [`wac`](https://github.com/bytecodealliance/wac#readme)
* [`dfx`](https://support.dfinity.org/hc/en-us/articles/10552713577364-How-do-I-install-dfx)### Motoko Compiler
Since cross-language support relies on [this unmerged PR](https://github.com/dfinity/motoko/pull/4580), it's currently necessary to use a custom version of the Motoko compiler. You can set this up with the following steps:
```sh
# Open a terminal in the root of this repository
cd ..
git clone https://github.com/dfinity/motoko.git
cd motoko
git checkout ryan/component-call
```We can remove this step after merging the corresponding PR.
### 📜 Scripts
The starter project includes Bash files in the `/scripts` directory to create and run a Motoko + Rust component.
**Build the component:**
```sh
scripts/build.sh
```**Build and run in Wasmtime:**
```sh
scripts/run.sh
```