Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Ethereum Projects for Beginners

You're reading from   Ethereum Projects for Beginners Build blockchain-based cryptocurrencies, smart contracts, and DApps

Arrow left icon
Product type Paperback
Published in Jul 2018
Publisher Packt
ISBN-13 9781789537406
Length 106 pages
Edition 1st Edition
Arrow right icon
Toc

Signing a document on the blockchain 

This section will teach you how to sign documents such as contracts on the blockchain. Let us consider the following code to understand how this is done:

pragma solidity ^0.4.17;
contract UserExample {

mapping(address => bool) user_verified;
mapping(address => bytes32) user_codes;

mapping(bytes32 => address) to_sign;
mapping(bytes32 => bool) signed;

address owner;

modifier onlyOwner() {
require(msg.sender == owner);
_;
}

function UserExample() public {
owner = msg.sender;
}

function inviteUser(bytes32 documentHash, address user) public onlyOwner {
to_sign[documentHash] = user;
}

function signDocument(bytes32 documentHash) public {
if (msg.sender != to_sign[documentHash]) {
revert();
}
signed[documentHash] = true;
}
function addUser(address user, bytes32 hashed_verification) public onlyOwner {
user_verified[user] = false...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime