Coding Verifiable Components
Proven Network uses a virtual machine which can run code targeting the WASM Component Model. Let's look at an example component!
package component:rps-example;
world rps-example {
import @proven-network:storage/identity-kv;
enum move {
rock,
paper,
scissors,
}
enum outcome {
win,
loss,
draw,
}
record metrics {
played: u32,
won: u32,
lost: u32,
drawn: u32,
}
export play: func(move: move) -> outcome;
export score: func() -> metrics;
}Here we're defining a simple rock-paper-scissors games which allows player to call a play function with their selected move and get an outcome in return.
WIT files are used by language-specific build tools to automatically handle all required codegen. Let's implement the play function in Rust using the cargo-component tooling.
Accessing persistent storage
Coming soon
Further reading on the Webassembly Component Model
Further documentation on the WA Component Model can be found on the Bytecode Alliance documentation site: https://component-model.bytecodealliance.org/
Last updated