Skip to main content

Contract Reference

Complete public interface documentation for all four Writz Soroban contracts. Testnet addresses:

bitcoin-spv

verify_transaction

Verifies that a Bitcoin transaction is included in a confirmed block. Stateless - no headers are stored on-chain.
Returns (SpvVerificationResult, defined once in the shared spv-types crate and used by every contract that calls into bitcoin-spv - not a per-contract duplicate):
There is no output-parsing/address-matching helper on-chain - a caller that needs to know which output paid a given address parses raw_tx itself.

set_vkey

Stores a Groth16 verification key for a circuit type. Admin only.

verify_groth16

Verifies a Groth16 BN254 proof against a stored verification key.
Returns: true if the proof is valid. false if the pairing check fails. Transaction panics (host rejects) if the proof contains invalid curve points.

commitment-tree

initialize

deposit

Verifies a Bitcoin deposit (via SPV) and a ZK deposit proof, then queues a commitment for insertion.
Emits: DepositVerified { txid: BytesN<32>, commitment: BytesN<32> }

insert_commitment

Inserts the next pending commitment into the Poseidon Merkle tree. Admin only in Phase 1.
Emits: CommitmentInserted { commitment: BytesN<32>, root: BytesN<32>, index: u32 }

borrow

Issues a USDC loan. Amount is extracted from the ZK proof - not supplied by the caller.
Emits: Borrowed { nullifier: BytesN<32>, new_commitment: BytesN<32>, amount: i128 }

repay

Repays outstanding USDC debt (full or partial).
Emits: Repaid { nullifier: BytesN<32>, new_commitment: BytesN<32>, amount: i128 }

liquidate

Liquidates an undercollateralized position. The usdc_debt amount is extracted from the proof.
Emits: Liquidated { nullifier: BytesN<32>, usdc_debt: i128 }

supply_usdc

Supplies USDC to the lending pool.

withdraw_supply

Withdraws USDC from the lending pool.

get_merkle_root

Returns the current Poseidon Merkle root.

TTL Refresh Functions (permissionless)


private-lend

initialize

deposit

borrow

repay

liquidate

Keeper-only in Phase 1.

get_position


Events Reference

All events use Soroban’s #[contractevent] annotation and are emitted in the transaction ledger.