Skip to main content

GramChain Intro

Let's go through the what, why and how of GramChain in less than 5 minutes.

What is GramChain?

GramChain is a event based logistics blockchain service. Events that happens in the chain are hashed and then broadcasted on chain.

The hashes for each individual parcels are hashed separately, so that if there is any tampering done in the chain this would be immediately available to the public.

Why GramChain?

GramChain provides a mechanism to provide proof of existence of a particular asset inside a vault. This transparency is critical in today's world where companies declare/manipulate their data in order to show increase in reserves etc.

How does it work?

The gramchain system relies on a set of API's which can be found here - https://api-prod.gramchain.net/api-docs/

The general process is that a particular parcel is scanned into the vault and then assigned to an entity. The entity can then decide to lock it for a particular process.

The metadata for each of these events are hashed and then broadcast to the blockchain. The general smart contract for this is as below:



pragma solidity 0.5.13;

import "openzeppelin-solidity/contracts/GSN/Context.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";

contract GramChain is Ownable {
// Map if hash has been submitted to contract
mapping (bytes32 => bool) private _containsMap;
// The actual hash event
event AddedHashEntry(bytes32 indexed hash);
// adding entries only if it doesn't already exist and it's the owner
function addHashEntry(bytes32 dataHash) external onlyOwner {
require(!_containsMap[dataHash], "The given hash already exists");
_containsMap[dataHash] = true;
emit AddedHashEntry(dataHash);
}
// adding entries only if it doesn't already exist and it's the owner
function addHashEntries(bytes32[] calldata hashlist) external onlyOwner {
for (uint i=0; i < hashlist.length; i++) {
bytes32 dataHash = hashlist[i];
require(!_containsMap[dataHash], "The given hash already exists");
_containsMap[dataHash] = true;
emit AddedHashEntry(dataHash);
}
}
// Verify hash exists in contract
function verifyDataHash(bytes32 dataHash) external view returns (bool) {
return _containsMap[dataHash];
}
}

The contract is rather simple and just emits the added hash entry into the blockchain.