Loam SDK
A Software Development Kit (SDK) and build tool for writing smart contracts in Rust on Wasm blockchains.
Currently, the focus is on the Soroban VM, but the same ideas apply to other VMs.
Table of Contents
Getting Started
Installation
To install just, run the following command:
Setup
To set up the environment, run:
Redeploy
To see redeployment in action, use:
Contract Riffs
A contract riff (or mixin) is a type that implements the IntoKey trait, which is used for lazily loading and storing the type.
Creating Contract Riffs
Here's an example of how to create a contract riff:
;
This generates the following implementation:
External API
You can also create and implement external APIs for contract riffs:
CoreRiff
The CoreRiff trait provides the minimum logic needed for a contract to be redeployable. A contract should be able to be redeployed to another wasm binary that can also be redeployed. Redeployment requires the contract to have an admin, as it would be undesirable for any account to redeploy the contract.
Using the CoreRiff
To use the core riff, create a Contract structure and implement the CoreRiff for it. The Contract will be redeployable and will be able to implement other Riffs.
use ;
use ;
;
soroban_contract!;
This code generates the following implementation:
;
By specifying the associated Impl type for CoreRiff, you enable the default Admin methods to be used (admin_set, admin_get, redeploy). However, you can also provide a different implementation if needed by replacing Admin with a different struct/enum that also implements IsCoreRiff.
Notice that the generated code calls Contract::redeploy and other methods. This ensures that the Contract type is redeployable, while also allowing for extensions, as Contract can overwrite the default methods.