A workspace containing Kryo API and State Prover services for handling state transitions and Merkle proofs.
docker run -d --name nats -p 4222:4222 nats -jssudo apt-get install libsnappy-devbrew install rocksdb- Start the Kryo API:
cargo run --bin kryo-api- Start the Kryo State Prover:
cargo run --bin kryo-provercurl -X POST http://localhost:3000/batch \
-H "Content-Type: application/json" \
-d '{
"transitions": [
{
"app_id": "test_app",
"entity_id": "user1",
"asset_id": "usdc",
"delta": 100,
"tx_id": "tx1"
},
{
"app_id": "test_app",
"entity_id": "user2",
"asset_id": "usdc",
"delta": 50,
"tx_id": "tx2"
}
]
}'Response:
{
"timestamp": 1234567890,
"affected_keys": ["test_app/user1/usdc", "test_app/user2/usdc"]
}curl -X POST http://localhost:3000/proof \
-H "Content-Type: application/json" \
-d '{
"key": "test_app/user1/usdc",
"timestamp": null
}'Response:
{
"root_hash": "876ed29c8d870f406f0675cd0be84478577cd6b347081261dd482b68909f8c93",
"timestamp": "2024-03-14T12:34:56Z",
"proof": [...],
"balance": 100
}curl http://localhost:3000/unprocessed-batchescurl -X POST http://localhost:3000/mark-processed \
-H "Content-Type: application/json" \
-d '{
"timestamp": 1748435837
}'brew install nats-io/nats-tools/natsnats sub kryo.transactionsnats pub state_transitions "$(cat payload.json)"- Submit a batch of transitions:
curl -X POST http://localhost:3000/batch \
-H "Content-Type: application/json" \
-d '{
"transitions": [
{
"app_id": "test_app",
"entity_id": "user1",
"asset_id": "usdc",
"delta": 100,
"tx_id": "tx1"
},
{
"app_id": "test_app",
"entity_id": "user2",
"asset_id": "usdc",
"delta": 50,
"tx_id": "tx2"
}
]
}'- Check unprocessed batches:
curl http://localhost:3000/unprocessed-batches- Mark a batch as processed:
curl -X POST http://localhost:3000/mark-processed \
-H "Content-Type: application/json" \
-d '{
"timestamp": 1234567890
}'- Submit another batch:
curl -X POST http://localhost:3000/batch \
-H "Content-Type: application/json" \
-d '{
"transitions": [
{
"app_id": "test_app",
"entity_id": "user1",
"asset_id": "usdc",
"delta": -30,
"tx_id": "tx3"
}
]
}'- Verify unprocessed batches again:
curl http://localhost:3000/unprocessed-batches