No description
  • Rust 92.1%
  • Shell 5%
  • Makefile 2.9%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2025-10-18 12:42:30 +02:00
common BVM functions implementation status 2025-10-17 15:12:53 +02:00
Shaders copy vault 2025-10-17 00:41:51 +02:00
.gitignore Batman 2025-01-11 21:56:11 +01:00
build.sh multi-contract 2025-10-17 00:29:42 +02:00
Cargo.toml multi-contract 2025-10-17 00:29:42 +02:00
Makefile multi-contract 2025-10-17 00:29:42 +02:00
README.md Update README.md 2025-10-18 12:42:30 +02:00

Beam Shader in Rust language (in development)

Beam shader with C++ bvm bindings for Rust

Project Structure

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

Usage

  1. Install rustup on your system. See rust installation instructions here.
  2. Install rust toolchain: $ rustup toolchain install stable
  3. Add wasm32-wasi target $ rustup target add wasm32-wasi

Building Contracts

# Build all contracts
$ make

# Build a specific contract
$ make build-contract CONTRACT=HelloWorld

# List available contracts
$ make list-contracts

# Clean build artifacts
$ make clean

Option 2: Using Build Script

# Build all contracts
$ ./build.sh

# Build a specific contract
$ ./build.sh HelloWorld

Option 3: Using Cargo Directly

# 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 contract

Output Structure

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

Adding New Contracts

To add a new contract:

  1. Create a new directory under Shaders/ (e.g., Shaders/MyContract/)
  2. Add app/ and contract/ subdirectories with their respective Cargo.toml and src/lib.rs files
  3. Update the root Cargo.toml workspace members to include your new contract paths
  4. Ensure both app and contract depend on the common crate

Originally developed by https://github.com/iKapitonau/beam_shader_rust