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 44 bytes (UTF-8) |
|---|---|
| keccak256 | 0xc29e5cb59341a0aeec23a6643f5953026ace70baac5f0495759e39caf48bb569 |
| sha256 | 0x2d9c5a46b0fbe8b39f06ae8819fbd6d17f28dc272352897db7a7136708b6372b |
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.