Skip to content

Astervia/zaphenath-cli-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zaph CLI

A command-line interface for interacting with the Zaphenath smart contract — a protocol for secure, time-locked data access based on user inactivity.

📦 Installation

Prerequisites

  • Rust
  • An Ethereum-compatible RPC endpoint (e.g., Anvil, Infura)
  • A deployed Zaphenath contract (or use --mock mode for local testing)

Clone and Build

git clone https://github.com/Astervia/zaphenath-cli-client.git
cd zaphenath-cli-client
cargo build --release

Optionally, install globally

cargo install --path .

Once installed, you can invoke the CLI via:

zaph --help

🧠 About Zaphenath

Zaphenath is a Solidity-based smart contract system for securely storing and revealing sensitive data (like wills, contingency plans, or secrets) after a period of user inactivity.

The core logic is based on:

  • Encrypted data keys linked to an owner
  • Timeouts that define when custodians may access data
  • Pings to prove liveness and keep data private
  • Role-based access control for delegated custody

📖 Read the whitepaper

🧰 CLI Command Structure

zaph <COMMAND> [OPTIONS]

Top-level commands

Command Description
config Manage local configuration and key metadata
contract Interact directly with the smart contract
daemon Run a background service to auto-ping keys

🛠 Basic Usage

1. Initialize your config

zaph config init

This creates a local config file (e.g., ~/.config/zaphenath/config.json) used for storing key metadata.

2. Create a key

zaph contract create-key \
  --key-id my-will \
  --data deadbeefcafebabe \
  --timeout 604800 \
  --contract-address 0xYourZaphenathAddress \
  --private-key-path ./my-key.hex \
  --rpc-url http://localhost:8545 \
  --yes
  • --data is a hex-encoded string (your encrypted payload)
  • --timeout is in seconds (e.g. 7 days = 604800)

3. Ping a key to keep it private

zaph contract ping-key --key-id my-will --yes

4. Read key data

zaph contract read-key --key-id my-will --decode

Use --decode to attempt UTF-8 decoding of the hex data.

5. Assign a custodian

zaph contract set-custodian \
  --key-id my-will \
  --user-address 0xFriend \
  --role Reader \
  --can-ping true

🌀 Daemon Usage

The daemon can automatically ping all keys in your config on a schedule:

Run in foreground

zaph daemon run --interval 60

Run in detached mode (background)

zaph daemon run --interval 60 --detached

Stop the daemon

zaph daemon stop

View logs

zaph daemon logs

🔍 Configuration File

The config file stores keys you've created or imported. Each entry contains:

{
    "key_id": "my-will",
    "owner": "0xYourAddress",
    "contract_address": "0x...",
    "private_key_path": "./my-key.hex",
    "network": "anvil",
    "rpc_url": "http://localhost:8545",
    "timeout": 604800,
    "custodians": [],
    "last_ping_timestamp": 1721019123
}

You can override the config path with:

zaph --config /path/to/custom_config.json ...

🧪 Mock Mode for Testing

Use --mock to skip actual blockchain interaction and simulate behavior:

zaph contract create-key --mock ...
zaph daemon run --mock ...

🧱 Project Structure

.
├── src
│   ├── main.rs               # CLI entrypoint
│   ├── cmd/                  # CLI command implementations
│   ├── contract/             # Ethereum interaction logic
│   ├── config.rs             # Config loading/saving
│   └── ...
├── abi/Zaphenath.json        # ABI definition
├── tests/                    # Integration tests
├── Makefile                  # Dev/test helpers
└── Cargo.toml

🛡 Safety Tips

  • Always use a private key stored securely (consider using encrypted keystores)
  • Back up your config files and encrypted data
  • Test in mock mode or on a testnet before using mainnet

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors