UNITS is a modular WebAssembly runtime system designed for financial transactions and asset management. At its core, it provides a secure and flexible environment for executing WebAssembly modules while managing financial assets through a driver-based architecture.
Starting with UNITS requires Rust 1.75 or later and a few core dependencies. First, ensure you have Rust installed with component support and the Protocol Buffers compiler. You'll also need SQLite for data persistence.
Begin by cloning the repository:
git clone https://github.com/yourusername/units.git
cd unitsBefore building the project, set up your environment variables for authentication:
export UNITS_USERNAME=your_username
export UNITS_PASSWORD=your_password
export secret=your_jwt_secretNow initialize your database:
sqlite3 units.db < migrations/20250206_000000_create_table.sqlYou can now build and start the server:
cargo build --release
cargo run --release -- config/development.tomlFor development with debug logging enabled:
RUST_LOG=debug cargo run -- config/development.tomlUNITS exposes its functionality through a gRPC API. Here's how to interact with the key services:
Create a new user and get authentication token:
# Sign up
grpcurl -plaintext -d @- localhost:8080 units.UserSignUp/SignUp << EOM
{
"user_name": "testuser",
"name": "Test User",
"email": "[email protected]",
"password": "testpass123"
}
EOM
# Log in and get JWT token
grpcurl -plaintext -d @- localhost:8080 units.UserLogin/Login << EOM
{
"user_name": "testuser",
"password": "testpass123"
}
EOMLoad a driver into the system:
grpcurl -plaintext -d @- localhost:8080 units.Driver/LoadDriver << EOM
{
"driver_name": "example-driver",
"driver_version": "1.0.0",
"driver_binary": "$(base64 -w0 path/to/driver.wasm)"
}
EOMSubmit and execute a program:
# Submit program
grpcurl -plaintext -d @- localhost:8080 units.Execution/Submit << EOM
{
"name": "example-program",
"version": "1.0.0",
"binary": "$(base64 -w0 path/to/program.wasm)"
}
EOM
# Execute program (include your JWT token)
grpcurl -plaintext \
-H "Authorization: your.jwt.token" \
-d @- localhost:8080 units.Execution/Execute << EOM
{
"input": "{\"action\":\"transfer\",\"amount\":100}",
"program_id": "your-program-id"
}
EOMList available drivers:
grpcurl -plaintext -d @- localhost:8080 units.DriverDetails/SendDetails << EOM
{}
EOMUNITS employs a three-tier "burger architecture" that cleanly separates concerns across different layers of the system. The Process Layer sits at the top, handling user workflows and WebAssembly module execution. Below it, the Driver Layer manages asset abstractions and permissions. The Platform Layer forms the foundation, handling system operations and storage.
This architecture enables UNITS to maintain strong isolation between different components while providing flexible integration points. Each layer communicates through well-defined interfaces, making the system both modular and extensible.
When developing with UNITS, you'll typically work with two main components: drivers and programs. Drivers provide the interface to underlying assets, while programs implement the business logic that operates on these assets.
To create a new driver:
./scripts/create-driver.sh my-driver
cd modules/drivers/my-driverFor a new program:
./scripts/create-program.sh my-program
cd modules/programs/my-programThe project includes a comprehensive test script that builds the runtime, starts the server, loads test drivers, and verifies everything works correctly:
./test.shUNITS provides two interface options for different use cases. The Terminal UI offers a lightweight, command-line interface perfect for development and scripting:
cd ui/units-tui
cargo runThe Web UI provides a more visual, user-friendly interface:
cd ui/units-ui
npm install
npm startWe welcome contributions to UNITS. Start by forking the repository and creating a feature branch for your work. After making your changes, submit a pull request. See our development guidelines in DEVELOPMENT.md for more details.
If you need help or want to contribute, you can open an issue, start a discussion, or browse our documentation. Join our community and help make UNITS better for everyone.
UNITS is available under the MIT License, allowing for both personal and commercial use with proper attribution.