Supply Chain on Blockchain

Supply ChainFree Lesson

Advertisement

Supply Chain on Blockchain

Track and trace, provenance, logistics, and supply chain transparency.

Overview

Blockchain provides transparent, immutable supply chain records.

Supply Chain Contract

contract SupplyChain {
    struct Product {
        string name;
        address manufacturer;
        address currentOwner;
        uint256 timestamp;
        string location;
    }
    
    mapping(uint256 => Product) public products;
    mapping(uint256 => Product[]) public history;
    
    function createProduct(uint256 id, string calldata name) public {
        products[id] = Product(
            name,
            msg.sender,
            msg.sender,
            block.timestamp,
            ""
        );
    }
    
    function transfer(uint256 id, address to, string calldata location) public {
        require(products[id].currentOwner == msg.sender);
        
        history[id].push(products[id]);
        
        products[id].currentOwner = to;
        products[id].timestamp = block.timestamp;
        products[id].location = location;
    }
}

Provenance Tracking

class ProvenanceTracker:
    def __init__(self):
        self.product_id = None
        self.origin = None
        self.journey = []
    
    def add_checkpoint(self, location, handler, timestamp):
        self.journey.append({
            "location": location,
            "handler": handler,
            "timestamp": timestamp,
            "verified": True
        })
    
    def get_full_journey(self):
        return self.journey

Use Cases

IndustryApplication
FoodFarm to table tracking
PharmaDrug authenticity
LuxuryAnti-counterfeiting
LogisticsShipment tracking

Benefits

  1. Transparency — All participants see data
  2. Immutability — Cannot alter records
  3. Efficiency — Automated verification
  4. Trust — Verified provenance

Practice

Build a supply chain tracking system for food products.

Advertisement

Need Expert Blockchain Help?

Get personalized Web3 training or smart contract consulting.

Advertisement