Semantic Web and Web 3.0 · class 11 · demo
Anchor a document
On chain goes the digest — 32 bytes — never the document. Type a document: the page computes its digest and asks the contract
whether it has it, with get(digest). As in example 06, the certificates' «document» is their URI, so typing a certificate URI finds it.
The digests
| Function | Digest of these 15 bytes (UTF-8) |
|---|---|
| keccak256 | 0x2c9bbfcf5410f3720d92358b15ca3371e074cef5f3a1e4d286fa45e9f06b774c |
| sha256 | 0x08d8c0fcc8bfdd7b8e80558d865ffd85ce282af094717ef35897c663c8c5593e |
Both are 32 bytes, so either fits a bytes32. The class uses keccak256 (what Solidity and ethers call
natively); a registry must just say which one. One character more — a space, a newline — and both change completely.
On the chain?
Not registered
get(digest) → author 0x000…000, registeredAt 0, uri ""
A mapping has no «not found»: an unknown key reads as zeros, and the author is what tells them apart.
An in-memory chain (the Ethereum virtual machine, @ethereumjs/evm), in this one process: no test network, no wallet, no keys, no money. Nothing a visitor does is kept.