| Crates.io | zescrow-core |
| lib.rs | zescrow-core |
| version | 0.1.0 |
| created_at | 2025-07-16 04:28:37.675644+00 |
| updated_at | 2025-07-16 04:28:37.675644+00 |
| description | Core library for Zescrow: zero-knowledge escrow transactions via RISC Zero zkVM |
| homepage | https://github.com/maatlabs/zescrow |
| repository | https://github.com/maatlabs/zescrow |
| max_upload_size | |
| id | 1754902 |
| size | 88,774 |
Core library for Zescrow: zero-knowledge escrows via the RISC Zero zkVM.
asset — chain-agnostic asset types (coins, tokens, NFTs, LP shares)condition — cryptographic conditions (hashlocks, signatures, threshold)escrow — off-chain escrow state machine with ZK proofsidentity — identity parsing and format conversions (hex, Base58, Base64)interface — schemas, I/O helperserror — typed errorsbignum — wrapper around BigUint.serde — JSON (de)serialization helpers (json feature)| Feature | Dependencies |
|---|---|
bincode (default) |
bincode (derive) |
json |
serde, serde_json, serde_bytes, serde_with |
Add the crate as a dependency in your Cargo.toml (enable the json feature if you want serde support):
[dependencies]
zescrow-core = { version = "0.1", features = ["json"] }
use zescrow_core::{
Asset, BigNumber, Condition, Escrow, EscrowError, ExecutionState, ID, Party, Result
};
use sha2::{Digest, Sha256};
fn execute_escrow() -> Result<()> {
let sender = Party::new("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045")?;
let recipient = Party::new("0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8")?;
let asset = Asset::token(
ID::from("0xdeadbeef".as_bytes()),
BigNumber::from(1_000u64),
BigNumber::from(2_000u64),
18,
);
let preimage = b"secret".to_vec();
let hash = Sha256::digest(&preimage);
let condition = Condition::hashlock(hash.into(), preimage);
let mut escrow = Escrow::new(sender, recipient, asset, Some(condition));
escrow.state = ExecutionState::Funded; // Advance execution state
let exec_state = escrow.execute()?;
if exec_state != ExecutionState::ConditionsMet {
return Err(EscrowError::InvalidState);
}
Ok(())
}
Licensed under either Apache License, Version 2.0
or MIT License at your option.