Skip to content

A DApp manages employee attendance and details using Golang and Solidity.

Notifications You must be signed in to change notification settings

hndev2404/d-app-timekeeping

Repository files navigation

GO Backend - Smart Contract

A DApp manages employee attendance and details using Golang and Solidity. It leverages blockchain tech for transparency and security. Golang handles the backend, while Solidity creates smart contracts for recording and validating attendance on the blockchain.

Docs

🛠 Built With

Go Badge Gin Badge Geth Badge Solidity Badge

Run Locally

Environment

  • Go: go1.22.2 linux/amd64
  • Docker: 25.0.3, build 4debf41
  • Node: v18.18.0
  • Solc: 0.8.25+commit.b61c2a91.Linux.g++
  • Abigen: 1.14.3-stable
  • Migrate 4.17.1

Clone the project.

git clone https://github.com/hndev2404/interview_prj
cd interview_prj

Smart Contract compilation & ABI

Install sol

sudo apt-get install solc

Install abigen.

go install github.com/ethereum/go-ethereum/cmd/abigen

Compile Daemon

Very simple compile daemon for Go

go install github.com/githubnemo/CompileDaemon

Deploy Smart Contract

  1. Generate Go binding for contract.

    make init-contract
  2. Update .env

    BC_DIAL_CLIENT Dial connects a client to the given URL.

    BC_ACCOUNT_PRIVATE_KEY The account using for deploy smart contract (Owner)

    BC_DIAL_CLIENT=<dial client>
    BC_ACCOUNT_PRIVATE_KEY=<private key>
  3. Deploy smart contract

    make deploy-contract

    After the deploy succeed we will get address of contract in folder ./logs with format name: ./logs/deploy_smart_contract_YYYY-MM-DD_HH:mm:ss.log

    Copy the contract address from the terminal and paste it in .env.

    BC_CONTRACT_ADDRESS=<contract address>

    For example:

    2024/05/16 22:00:31 Transaction has been committed!!
    2024/05/16 22:00:31 --------------------------------
    2024/05/16 22:00:31 Contract Address: 0xc2Fb27e49491ceeB451403c19b783a78F7E903dD
    2024/05/16 22:00:31 -----------------
    2024/05/16 22:00:31 Transaction Hash: 0xfd8b30e0c96b2606af207dd98b1f6fbc58514285286ca5b589ed0209c7c163a9
    2024/05/16 22:00:31 -----------------
    

Start Application

  1. Start Postgres & Adminer for Database

    make up
  2. Init database

    make migrate up

    Or execute SQL queries directly at migrations/init.sql

  3. Run app on local

    make dev

    The application will run on PORT has been defined in .env.

About

A DApp manages employee attendance and details using Golang and Solidity.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published