Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Athena Consulting has been awarded a grant by [Atom Accelerator DAO](https://www
- [TimeLock Contract](https://github.com/athena-consulting/cosmwasm-by-example/tree/main/timelock)
- [Crowdfunding Contract](https://github.com/athena-consulting/cosmwasm-by-example/tree/main/crowdfunding)
- [Token Vault](https://github.com/athena-consulting/cosmwasm-by-example/tree/main/token-vault)
- [Hash Notary](https://github.com/athena-consulting/cosmwasm-by-example/tree/main/hash-notary)

### :three: Complex Applications
- [Constant Product AMM](https://github.com/athena-consulting/cosmwasm-by-example/tree/main/constant-product-amm)
Expand Down
48 changes: 48 additions & 0 deletions hash-notary/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[package]
name = "hash-notary"
version = "0.1.0"
authors = ["nunezve"]
edition = "2021"

exclude = [
"contract.wasm",
"hash.txt",
]

[lib]
crate-type = ["cdylib", "rlib"]

[profile.release]
opt-level = 3
debug = false
rpath = false
lto = true
debug-assertions = false
codegen-units = 1
panic = 'abort'
incremental = false
overflow-checks = true

[features]
backtraces = ["cosmwasm-std/backtraces"]
library = []

[package.metadata.scripts]
optimize = """docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.10
"""

[dependencies]
cosmwasm-schema = "1.1.3"
cosmwasm-std = "1.1.3"
cosmwasm-storage = "1.1.3"
cw-storage-plus = "1.0.1"
cw2 = "1.0.1"
schemars = "0.8.10"
serde = { version = "1.0.145", default-features = false, features = ["derive"] }
thiserror = "1.0.31"

[dev-dependencies]
cw-multi-test = "0.16.2"
92 changes: 92 additions & 0 deletions hash-notary/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Hash Notary

Hash Notary is a simple CosmWasm contract for timestamping document or artifact hashes without storing private file contents on chain.

Users register a SHA-256 digest with a short label and optional memo. The contract stores the normalized digest, the sender, the block timestamp, and an active flag. The original proof remains queryable even if the owner later revokes it.

## Messages

### Instantiate

```json
{}
```

### Register

```json
{
"register": {
"digest": "b94d27b9934d3e08a52e52d7da7dabfade035a3e5094b9f9f1795f7c4f3819d0",
"label": "service-agreement.pdf",
"memo": "Signed PDF hash"
}
}
```

### Update Memo

```json
{
"update_memo": {
"id": 1,
"memo": "Updated internal reference"
}
}
```

### Revoke

```json
{
"revoke": {
"id": 1
}
}
```

## Queries

### Get Record

```json
{
"get_record": {
"id": 1
}
}
```

### Get Record By Digest

```json
{
"get_record_by_digest": {
"digest": "0xb94d27b9934d3e08a52e52d7da7dabfade035a3e5094b9f9f1795f7c4f3819d0"
}
}
```

### List Records

```json
{
"list_records": {
"start_after": 10,
"limit": 20
}
}
```

## Validation

- Digests must be SHA-256 hex strings, with or without a `0x` prefix.
- Labels must be non-empty and at most 80 characters.
- Memos are optional and at most 240 characters.
- Only the record owner can update a memo or revoke the record.

## Tests

```bash
cargo test --manifest-path hash-notary/Cargo.toml
```
17 changes: 17 additions & 0 deletions hash-notary/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::env::current_dir;
use std::fs::create_dir_all;

use cosmwasm_schema::{export_schema, remove_schemas, schema_for};

use hash_notary::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};

fn main() {
let mut out_dir = current_dir().unwrap();
out_dir.push("schema");
create_dir_all(&out_dir).unwrap();
remove_schemas(&out_dir).unwrap();

export_schema(&schema_for!(InstantiateMsg), &out_dir);
export_schema(&schema_for!(ExecuteMsg), &out_dir);
export_schema(&schema_for!(QueryMsg), &out_dir);
}
Loading