Lock.host WASM JS example, see Lock.host
This demonstration uses OpenAI to control a Solana wallet:
- Unmodified OpenAI lib
- (Mostly) Unmodified Solana lib
- Hit /api/joke?message=your best joke&addr=abc123
- OAI is asked "You are to decide if a joke is funny or not"
- If so 0.001 SOL is sent to addr
- jokes are written to SQLite by SQLiteWasmWasi
Lock.host-node demonstrates the same features but is expensive to host
Lock.host-python also demonstrates the same features and is expensive to host
It is very efficient to host WASM apps and so Lock.host has started in this direction
apt install just (or brew install just)
curl https://wasmtime.dev/install.sh -sSf | bash
You also need wac and this one takes a few minutes:
cargo install wac-cli
cp example.env .env
just build
just run
just joke 'why did the worker quit his job at the recycling factory? because it was soda pressing.'
> {"signature":"25ndS3qg8EsiaN1uEBfpb63QNdWZDma8ap5Cc5Hv3P4nBM4kAd3pLJQiZHFGpYSm9HLcrzkQaz1mvDrw4Yy4Hu4X","from":"DohcaGiBiC3yuPz4gHtoA7QJhyL5N7hk3EpnfFyHZR2S","to":"CFf6SMjR3eNKR7me9CGHhRNE1SwSQaPi5r4MWZQFGB2W","thoughts":"The joke plays on the pun between 'so depressing' and 'soda pressing', which is clever and light-hearted."}
sqlite3 mount/app.db "select * from jokes;"
> 1|CFf6SMjR3eNKR7me9CGHhRNE1SwSQaPi5r4MWZQFGB2W|why did the worker quit his job at the recycling factory? because it was soda pressing.|The joke plays on the pun between 'so depressing' and 'soda pressing', which is clever and light-hearted.|1
It has only very very recently become possible to compile JS to WASM
Specifically we use ComponentizeJS which compiles the Mozilla SpiderMonkey JS engine into WASM
The JS engine then parses and runs the app sources. Think of it like node but you dont have fs and Buffer
Because the runtime is exotic @solana/kit had to be patched to use @noble/ed25519
SQLiteWasmWasi is also very new
- npx loadtest -n 10000 http://localhost:8080 == 5675 RPS
- npx loadtest -n 10000 -k http://localhost:8080 == 6262 RPS
MIT