Thanks for your interest in HIMSHA (Hashable Instruction Machine). This is an educational, proof-of-concept Bitcoin programmability layer — see the disclaimer in the README. Contributions that improve clarity, correctness, and test coverage are very welcome.
- Rust 1.75+ (
rustuprecommended) - Bitcoin Core (regtest) for node integration work
- Optional: RISC Zero toolchain for real ZK proving:
cargo install cargo-risczero && cargo risczero install
cargo build --workspace
cargo test --workspaceBoth must pass cleanly before you open a PR. Keep the tree warning-free for code
you touch (cargo clippy --workspace is encouraged).
| Crate | Responsibility |
|---|---|
himsha-runtime |
Core shared types (accounts, tx, UTXO, receipts, errors, program IDs) |
himsha-vm |
Execution engine — native dispatch for built-ins + RISC Zero executor |
himsha-node |
JSON-RPC node, block producer, Bitcoin indexer, redb state |
himsha-programs/* |
On-chain programs (system, token, ata, swap, lending, nft-metadata, runes) |
himsha-cli |
Command-line client |
Every program is a normal Rust crate exposing:
pub fn process(accounts: &mut [AccountInfo], data: &[u8]) -> Result<(), ProgramError>;
// (lending & runes also take a `timestamp: u64`)The node executes built-ins natively through himsha-vm::dispatch. Real RISC Zero
proving (compiling each program to a guest ELF via risc0-build) is future work and
requires the RISC Zero toolchain.
- Create
himsha-programs/<name>/with aCargo.tomldepending onhimsha-runtime. - Define an instruction enum (borsh), builders, and a
process()entry point. - Add a
program_ids::<name>_program()seed inhimsha-runtime/src/lib.rsand include it inbuiltins(). - Wire it into
himsha-vm/src/dispatch.rsand add the path dependency inhimsha-vm/Cargo.toml. - Add the crate to the workspace
membersin the rootCargo.toml. - Add unit tests covering happy path + every error branch.
- Document it in the README program table.
- Use
checked_add/checked_sub/checked_mulfor all balance and reserve math; returnProgramError::Overflowrather than panicking. - Validate account counts (
NotEnoughAccounts) before indexing. - Prefer precise errors (
NotInitialized,Unauthorized,SlippageExceeded, …). - Match the surrounding style: borsh state structs, instruction builders,
process()dispatch.
- Branch from
main:feature/<short-desc>orfix/<short-desc>. - Keep commits focused; write imperative subject lines (
add runes program). - Fill out the PR template and confirm
cargo build+cargo testare green. - Describe what changed and why, and call out anything intentionally left as a stub or follow-up.
- Harden the opt-in RISC Zero guest path (
--features zkvm, seedocs/zkvm-proving.md): verify it in CI with the toolchain, and consider one image id per program instead of the shared universal guest. - Cross-program invocation (CPI) so
swapactually moves tokens via the token program. - Money-market refinements: a close factor capping liquidation size, a protocol
reserve cut on interest, and a price oracle (
himsha-programs/money-marketcovers supply/borrow/repay, LTV/health, interest accrual, and liquidation today). - Broadcast Ordinals loan settlements: the lending program queues settlement directives (with interest, partial repay, and bid cancellation) and the node drains/logs them — wire the actual Bitcoin transaction build + broadcast to the indexer.
- Full per-signer Schnorr verification at the node (programs now enforce
is_signerviaAccountInfo/cpi::invoke_signed_indexed; the node still only checks signature count). Extend signer checks to the ATA program. - Wire the lending settlement broadcaster and
himsha_getUtxoto a running Bitcoin indexer (setBITCOIN_RPC_URL/USER/PASS); both are env-gated today.