This is a demonstration of the application development process of a Valence ZK program.
First, start the co-processor.
cd $HOME
git clone https://github.com/timewave-computer/valence-coprocessor.git
cd valence-coprocessor
git checkout v0.1.2
cargo run-service
You should see as output the service initialized.
INFO config file loaded from `/home/joe/.config/valence-coprocessor-service/config.toml`...
INFO db loaded from `/home/joe/.local/share/valence-coprocessor-service`...
INFO registry loaded...
INFO API loaded, listening on `0.0.0.0:37281`...
INFO listening addr=socket://0.0.0.0:37281
INFO server started
INFO execute: clk = 0 pc = 0x2092e0
INFO execute: gas: 1020123
INFO execute: clk = 0 pc = 0x2092e0
INFO execute: gas: 1020123
Then, build the demo.
cd $HOME
git clone https://github.com/timewave-computer/valence-exchange-demo.git
cd valence-exchange-demo
make build
Finally, run the script
cargo run -p valence-exchange-demo-script --release
You should see the output
defined url `http://127.0.0.1:37281/api`...
defined module `308968` bytes...
defined zkvm `441992` bytes...
registered program `9806deb86237908b620c4f77f72a16c207329d47644a2a9f11f6350045d361c4`...
program state reset...
proof generated: `(94 bytes, 54 bytes)`
state updated to `{"balances":{"eur":87.90400000000001,"usd":1400.0}}`...
proof verified...
program state updated to {"balances":{"eur":87.90400000000001,"usd":1400.0}}...
To inspect the remote state:
curl -s http://127.0.0.1:37281/api/registry/program/9806deb86237908b620c4f77f72a16c207329d47644a2a9f11f6350045d361c4/storage | jq -r '.data' | base64 --decode
Where the url has been set with the API endpoint, and the contract hash has been passed as argument in the path. You should see the output
{"balances":{"usd":1500.0}}
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- WASM toolchain
rustup target add wasm32-unknown-unknown
sudo pacman -S clang llvm
Note: openssl-dev might also be required.
curl -L https://sp1up.succinct.xyz | bash
sp1up
cargo prove --version