Beam shader with C++ bvm bindings for Rust
root/
├── common/           # Common files that contracts need
├── Shaders/          # Individual contracts
│   └── HelloWorld/   # Example HelloWorld contract
│       ├── app/      # Manager/interface part
│       └── contract/ # Contract implementation
└── Cargo.toml        # Workspace configuration
- Install rustupon your system. See rust installation instructions here.
- Install rust toolchain:
$ rustup toolchain install stable
- Add wasm32-wasi target
$ rustup target add wasm32-wasi
# Build all contracts
$ make
# Build a specific contract
$ make build-contract CONTRACT=HelloWorld
# List available contracts
$ make list-contracts
# Clean build artifacts
$ make clean# Build all contracts
$ ./build.sh
# Build a specific contract
$ ./build.sh HelloWorld# Build all contracts (files will be mixed in target/wasm32-wasi/release/)
$ cargo build --target wasm32-wasi -r
# Build a specific contract
$ cargo build --target wasm32-wasi -r -p app -p contractWhen using the build scripts or Make, compiled wasm files are organized by contract:
target/wasm32-wasi/release/wasm/
├── HelloWorld/
│   ├── app.wasm
│   └── contract.wasm
└── [OtherContract]/
    ├── app.wasm
    └── contract.wasm
After that you can use app.wasm and contract.wasm files in the same way you use it in Beam's contracts (see https://github.com/BeamMW/shader-sdk/wiki/Running-Beam-Shaders-using-CLI-Wallet).
To add a new contract:
- Create a new directory under Shaders/(e.g.,Shaders/MyContract/)
- Add app/andcontract/subdirectories with their respectiveCargo.tomlandsrc/lib.rsfiles
- Update the root Cargo.tomlworkspace members to include your new contract paths
- Ensure both appandcontractdepend on thecommoncrate
Originally developed by https://github.com/iKapitonau/beam_shader_rust