Giter Club home page Giter Club logo

chain-sign's Introduction

Chainlink powered e-Document verification and signing using smart contracts, IPFS and chainlink APIs

LIVE DEMO

Built with:

Inspiration

Chainsign adds signing and verifying e-contract and document function to the blockchain. This solves legal issues involved with documents through use of chainlink and smart contracts

With blockchain, documents are embedded in digital code and stored in transparent, shared databases, where they’re protected from deletion, tampering and revision. Every agreement, every task, and every payment would have a digital record and signature that could be identified, validated, stored, and shared. Intermediaries like lawyers, brokers and institutions might no longer be necessary. Individuals and organizations would freely transact and interact with one another with little friction. This is the immense potential of blockchain.

What it does

Document upload flow

Chainlink

Certificates are issued by an authority, such as an education institute, legal institution stored oncentralized document management server, or on a distributed file system like IPFS and signed with a cryptographic function. The content hash and certificate’s metadata hash are then stored on the blockchain digital ledger and attached to the user’s digital identity as a smart contract address that stores this information This represents a sort of unique authenticity token, which identifies the document in a non-questionable way.

  • Signer has to LogIn
  • After LogIn has been successful you can upload a document.
  • You can sign uploaded document.
  • DocumentHash / Meta data hash is generated. DocumentHash should be stored on Blockchain. Signed document is stored on IPFS.

Document verification flow

Verification flow

Users who need to verify their certificates with a third party do so by sharing the authenticity token (that is, the file contract address), which contains all the necessary information to verify that the document exists and is authentic and not counterfeited.

The user retrieves the certificate to verify from its location and initiates a new transaction on the blockchain network, transferring the authenticity token to the verification authority. The authority obtains the signed content and metadata of the certificate being verified and then compares them with the equivalent hash values from the off-chain copy. If the values match, the document is verified End-to-end implementation of the following Chainlink features using Hardhat development environment and Next.js frontend framework:

Built with:

Document upload and signing flow

Verification flow

Requirements

In order to use the frontend portion of the demo application you will need

Quick Start

Clone the repo and install all dependencies:

git clone https://github.com/hackbg/chainlink-fullstack
cd chainlink-fullstack

git submodule init
git submodule update

yarn install

Start up the local Hardhat network and deploy all contracts:

yarn chain

In a second terminal start up the local development server run the front-end app:

yarn dev

To interact with the local network, follow this step-by-step guide on how to use MetaMask with a Hardhat node.

If you've set the mnemonic from MetaMask the first 20 accounts will be funded with ETH.

Environment Variables

To make setting environment variables easier there are .env.example files in the hardhat and frontend workspaces. You can copy them to new .env files and replace the values with your own.

Hardhat

Name Description
NETWORK_RPC_URL Required to deploy to public networks. Obtain from Infura's site.
MNEMONIC Used to derive accounts from wallet seed phrase, ie Metamask. The first account must have enough ETH to deploy the contracts, as well as LINK which can be obtained from Chainlink's faucets.
PRIVATE_KEY Alternative to using mnemonic. Some changes are required in hardhat.config.js
ETHERSCAN_API_KEY Verify contract code on Etherscan.

Front-end

Name Description
NEXT_PUBLIC_INFURA_KEY Read-only mode and WalletConnect.

Deploy Contracts

This will run the deploy scripts to a local Hardhat network:

yarn deploy

To deploy on a public network:

yarn deploy --network kovan

Auto-Funding

The Hardhat project will attempt to auto-fund any newly deployed contract that uses Any-API or VRF, which otherwise has to be done manually.

The amount in LINK to send as part of this process can be modified in this Hardhat Config, and are configurable per network.

Parameter Description Default Value
fundAmount Amount of LINK to transfer when funding contracts 1 LINK

If you wish to deploy the smart contracts without performing the auto-funding, run the following command when doing your deployment:

yarn deploy --tags main

Test

If the test command is executed without a specified network it will run locally and only perform the unit tests:

yarn test:contracts

Integration tests must be run on a public testnet that has Chainlink oracles responding:

yarn test:contracts --network kovan

For coverage report:

yarn coverage:contracts

Verify on Etherscan

You'll need an ETHERSCAN_API_KEY environment variable. You can get one from the Etherscan API site.

npx hardhat verify --network <NETWORK> <CONTRACT_ADDRESS> <CONSTRUCTOR_PARAMETERS>

example:

npx hardhat verify --network kovan 0x9279791897f112a41FfDa267ff7DbBC46b96c296 "0x9326BFA02ADD2366b30bacB125260Af641031331"

Format

Fix formatting according to prettier config in the respective workspace:

yarn format:frontend
yarn format:hardhat

Lint

yarn lint:frontend

Testnet Contracts

This repo includes deployed and verified contracts on Kovan and Rinkeby so the front-end can run without the need to deploy them.

Once the deploy command is executed on any network the contracts config will be overwritten and you can start from scratch with your own deployments.

Kovan

Name Address
PriceConsumerV3 0x01E2C7cA6D6A82D059287Cb0bC43a39Cd0ff4B00
FeedRegistryConsumer 0xB9ebb63D4820c45a2Db09d71cefA24daBd047b50
APIConsumer 0x14005AB90bc520E20Ffd7815Cae64372abb6b04d
RandomNumberConsumer 0xF9556187bf86823Cf0D7081625F97391642Fc242
RandomSVG 0xb4Bac68d9Fa99D2852E5dFb124be74de2E8c4F76

Rinkeby

Name Address
PriceConsumerV3 0x4998Bd433216bBc56976BCb4Fe5AA240bA766763
APIConsumer 0x43a87559277fd5F6F1AdC6e6331998899634e9Aa
RandomNumberConsumer 0xA0e617aaA36Ff4A6bf61C4Ce2Ed66822B1e24726
RandomSVG 0xeC6CcE025e538D12E52D8C90181849B099a776A3

References

chain-sign's People

Contributors

jayshreeanand avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

torans

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.