1

I m doing project for document verification using blockchain in which we don't have to carry documents everywhere, hash key of block will fetch data of doc from blockchain.I m not getting how to search through blockchain or what will be efficient method for searching through blockchain for finding block data belonging to that particular hash?

  • 1
    Hi there. Your question isn't clear. To check: are you talking about searching the Ethereum blockchain, or blockchains in general? (There will almost certainly be implementation differences.) How will you be storing that data "in a block"? – Richard Horrocks Jan 19 '19 at 19:04
  • You could set up an instance of an open source blockchain explorer for your chain, e.g. BlockScout github.com/poanetwork/blockscout . You can use GraphQL or RPC to query transaction and tokens. If you plan to do it on a public chain, e.g. Ethereum mainnet you could use a public hosted version at blockscout.com – Igor Barinov Jan 20 '19 at 18:24
2

Your use of terminology is quite confusing but I think I possibly understand what you're getting at. I will answer based on the following understanding.

  1. You want to record that a document exists by merely storing the hash of the document in a blockchain. We'll use Ethereum.
  2. You want to be able to check document authenticity by searching for the existence of that hash.
  3. It's probably helpful to know who registered a particular document.
  4. Anyone can register a document and anyone can inquire about who registered any (all) documents.

You won't be searching by block hashes. You'll have a contract that implements business rules. Users will send instructions to that contract and users will query that contract to get answers. The underlying blockchain provide assurance about the fidelity of the information in the contract and the censorship-resistance of the contract.

Simple is better.

Here's an example to get you thinking. It's a simple contract with two functions to set and get.

pragma solidity 0.5.2;

contract ProofOfExistance {

    mapping(bytes32 => address) public registry;

    event LogDocumentRegistered(address claimant, bytes32 document);

    function documentExists(bytes32 documentHash) public view returns(bool doesIndeed) {
        return(registry[documentHash] != address(0));
    }

    function recordExistance(bytes32 documentHash) public {
        require(!documentExists(documentHash));
        registry[documentHash] = msg.sender;
        emit LogDocumentRegistered(msg.sender, documentHash);
    }

}

Hope it helps.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.