Build your first smart contract: a document fingerprint register
Blockchain learning series 8 of 12
Deploy a small Solidity contract and explain exactly what it records.

Read the infographic as text
Build your first smart contract: a document fingerprint register
Deploy a small Solidity contract and explain exactly what it records.
- Hash locally
- Calculate a SHA-256 fingerprint from the file's bytes.
- Register once
- Record that fingerprint for the submitting address.
- Read the result
- Retrieve its recorded block number, not a legal ownership claim.
Learning goal: Deploy a small Solidity contract and explain exactly what it records.
Blockchain learning series 8 of 12. Educational diagrams; not a production architecture.
We will build a register that answers one narrow question: at which block did this address first submit this document fingerprint? It will not hold funds, issue a token or decide who owns a document. That small scope makes its behaviour possible to inspect from end to end.
This is the EVM development path introduced in the safe setup guide. Complete that lesson first, then use Remix VM or run the downloadable lab. The Solidity contract runs in an EVM environment, not directly on Bitcoin's base layer. Its programming model is separate from a public network's choice of PoW or PoS. If you are new to programming, read the explanation before copying the code, then change one small behaviour and predict the result.
Define the record before the function
The fingerprint is a SHA-256 digest of the file's bytes. SHA-256 produces 32 bytes, written here as 64 hexadecimal characters with an 0x prefix. The contract receives those bytes; it does not calculate the file's hash or receive the document itself.
Two files with different bytes will ordinarily have different digests, even if they look identical on screen. Saving a document again can change metadata and therefore its fingerprint. Our comparison concerns exact bytes, not visual similarity. MDN's digest documentation describes the browser operation used in the accompanying interface.
The complete contract
Code · solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
// Learning example. Not audited. Do not use for legal or ownership claims.
contract DocumentRegister {
mapping(address => mapping(bytes32 => uint256)) public recordedAt;
event Registered(address indexed submitter, bytes32 indexed fingerprint, uint256 blockNumber);
function register(bytes32 fingerprint) external {
require(fingerprint != bytes32(0), "Empty fingerprint");
require(recordedAt[msg.sender][fingerprint] == 0, "Already recorded");
recordedAt[msg.sender][fingerprint] = block.number;
emit Registered(msg.sender, fingerprint, block.number);
}
}The Solidity contract documentation explains the language features used here. The compiler version is pinned so that the lesson is reproducible. The licence line identifies the example's MIT licence; it does not certify its safety.
Read each part as a rule
The nested mapping behaves like a lookup with two keys: submitter address and fingerprint. Its value is the recorded block number. A missing entry reads as zero. Our simulation deploys the contract after the initial block, so a successful registration gets a positive number.
msg.sender identifies the immediate caller. The caller cannot supply another address to the registration function. This makes the entries caller-scoped, but it does not prove the caller's real identity. If a contract calls the register, that contract is the caller.
The first require rejects the all-zero value. This is an input rule for the lesson, not proof that every non-zero value came from a real file. The second rejects a repeat of the same caller and fingerprint. Both checks run before the state is changed.
The assignment stores block.number. The event emits the caller, fingerprint and block number so that clients can find the action in transaction logs. The persistent mapping supplies the direct lookup. Neither mechanism uploads or backs up the original document.
Compile, deploy and read an empty entry
In Remix, compile DocumentRegister.sol with 0.8.30 and the Paris EVM target. Select a Remix VM, keep the transaction value at zero and deploy DocumentRegister. Deployment creates an instance with an address and initially empty records.
Expand the deployed instance. Copy the currently selected VM account address. Call recordedAt using that address and this practice value:
Code · text
0x1111111111111111111111111111111111111111111111111111111111111111You should receive zero. This is a made-up 32-byte input used to learn the contract controls; it is not a claim about any document. Pass the same value to register, then read it again for the same account. You should receive the block number of the successful registration.
The lab's website calculates an actual SHA-256 fingerprint from a selected practice file. It uses exactly the same contract, while avoiding the need to copy long values by hand.
Predict the register behaviour
| Input | Expected result | Meaning |
|---|---|---|
| New non-zero fingerprint | Store current block number | Submission by this caller |
| Same caller and fingerprint | Reject | Preserve the first entry |
| Different caller, same fingerprint | Allow separate entry | No exclusive ownership awarded |
Know what you have not built
There is no identity verification, legal timestamping service, correction policy, administrator, upgrade mechanism or document storage. The function does not accept an ordinary ETH payment. Do not send assets to the address, and do not assume the absence of a payment function means no balance can ever arrive through every possible protocol mechanism.
A false statement or stolen document can be fingerprinted and registered. The interface must describe a submission by an address, not verified authorship. Anyone promising the latter needs an additional source of authority and a defensible process.
Try a prediction before the next guide: what happens when the same account submits the practice value twice? The second call should fail and the first block number should remain. We will test that behaviour, along with several less obvious cases.
Sources
Source note: We have made reasonable efforts to provide sources for material claims. Some third-party sources could not be accessed at publication.
Related reading
Guides ·
Connect a website to your smart contract
Run a local interface that hashes files, submits a transaction and reads the receipt.
Guides ·
Test a smart contract, including the things that should fail
Test duplicate submissions, invalid input, separate callers and unchanged state.
Guides ·
Your first crypto trade: pairs, prices and what you’re buying
Follow a hypothetical $100 crypto purchase. Learn trading pairs, fractional coins, order fills and what changes when you sell.
Guides ·
Why decentralised apps still use centralised cloud services
A smart contract can run across a distributed network while the website, data services and access points depend on a handful of providers. Resilience depends on the complete application.

