Skip to content

cbonoz/chainfa22

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



Blockfreight

Blockfreight is an open blockchain product tracking platform for any parcel.

Generates a unique blockchain-backed QR code that can either be presented or placed on the cargo of interest.

Built for the Chainlink Fall 2022 hackathon.

Demo video: https://youtu.be/1f7YgP_u_Qw

Testnet link: Blockfreight

Must be connected to Polygon testnet (Mumbai) for link above.

Motivation

Often excel spreadsheets that track the history of inventory and deliveries are shared via email, or stored in individual documents which can be harder to sync and maintain.

For other vendors using software platforms (such as Flexport), much of the data is held centrally within those platforms, subject to custom terms and conditions, and modifiable by their internal teams. Also often need to have a formal app B2B subscription plan.

Other common challenges that occur outside of platforms can include limitations from the non-universal nature of email (emails are private between sender and recipient), delays might not be accurately or consistently reported, and products might be lost.

Solution

Using Polygon smart contracts, Blockfreight can:

  1. Enable an immutable, append-only, history of interactions with given parcels.
  2. Create a permission framework (optional) that enforces only certain wallets or user accounts can log events against a given item.
  3. Store the data in a transparent way for all parties, where no single party has to be the custodian of the data log.
  4. Perform low cost, high volume, and fast transactions.

Once delivered/completed, the owner of the parcel can call the markCompleted contract method - the contract will no longer be able to be updated, but the record will be preserved on the Polygon blockchain and IPFS.

Technologies used

Polygon: Serves as the primary smart contract network for the Blockfreight application. Polygon enables fast and low cost smart contract transactions that make it easy to use Blockfreight in the field without heavy additional costs or time delays.

Chainlink: Grabs information about the checkpoints location at the time of parcel update and pulls into the smart contract. Uses an on-chain API call for reverse geolocation (via https://www.geoapify.com/reverse-geocoding-api) to store the provided lat/lng as a formatted location. For example, a known location of a shipping warehouse can automatically be pulled and saved on the smart contract without having the user type anything.

IPFS: Record keeping and storage. IPFS is used as the backend for the QR code scanning data lookup and enables uploading new images of the cargo at different checkpoints or if the status of the item has changed visibly during transit (ex: item experienced damage). Notes uploaded are also saved to the contract.

Every completed freight update via the QR code emits a FreightEvent that gets indexed and appended to the parcel's contract.

    emit FreightEvent(_requestId, lastSender, lat, lng, notes, _location);

Useful links

Running the app

Define the following environment variables.

    REACT_APP_COVALENT_KEY= // Your covalent API key (optional - needed from history tab)
    REACT_APP_STORAGE_KEY=  // Your web3.storage key.
    REACT_APP_ACTIVE_CHAIN_ID= // 80001 or 137 currently for polygon testnet or mainnet (defaults to testnet).
    REACT_APP_WC_ID= // cloud.walletconnect.com app id (defaults to a demo app id).

yarn; yarn start

Blockfreight should now be running on port 3000.

Note this project is currently a prototype and would require additional work to be production ready on Polygon mainnet.

Potential future work

  • Add subscription costs for creating different record types, auditing, and organization permissioning.
  • Enable data export of blockchain logs to more native or traditional formats such as excel or pdf.
  • Add support for user logins in addition to metamask (or wallet-based) logins.

Screenshots / User flow

Home

Creating a new parcel contract

Connecting wallet for contract deployment

Confirm contract creation

Contract created!

IPFS record on contract creation

Contract Metadata

QR code

Printing QR code

Providing a freight contract update

Freight update transaction added to contract record

Freight update event is emitted from the contract

Chainlink api call to reverse geocode latitutude/longitude to address string.

Freight history lookup