Skip to content

Commit

Permalink
improve README
Browse files Browse the repository at this point in the history
  • Loading branch information
sskeirik committed Dec 14, 2024
1 parent 5adc8b2 commit 2f66584
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 16 additions & 1 deletion tests/ulm/erc20/rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,19 @@ This directory contains a Rust implementation of an ERC20 contract that is compi
As is the case with many chains that use Wasm contracts, we compile this Rust project as a library;
that way, functions referenced in external libraries become host functions which can be provided via Wasm module imports.

In order to reduce the
In order to reduce the size of the compiled Wasm library, we referred to this guide:

https://github.com/johnthagen/min-sized-rust

To build the contract with all of the size minimization options, first, ensure that a recent build of the Rust compiler is installed with the Wasm32 target, which can be done with:

```sh
rustup install nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
```

Then run the build script as follows:

```sh
build.sh
```
3 changes: 2 additions & 1 deletion tests/ulm/erc20/rust/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
LOC_FLAG="-Zlocation-detail=none" # removes debugging info from binary
FMT_FLAG="-Zfmt-debug=none" # removes formatter code from binary
# the last two lines build stdlib for target with minimal panic handling and optimized for size
RUSTFLAGS="$LOC_FLAG $FMT_FLAG" cargo +nightly build --release --target wasm32-unknown-unknown \
-Z build-std=std,panic_abort \
-Z build-std=std,panic_abort \
-Z build-std-features="optimize_for_size,panic_immediate_abort"

0 comments on commit 2f66584

Please sign in to comment.