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.
- Overview System
- API Design:
- 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
git clone https://github.com/hndev2404/interview_prj
cd interview_prj
Install sol
sudo apt-get install solc
Install abigen.
go install github.com/ethereum/go-ethereum/cmd/abigen
Very simple compile daemon for Go
go install github.com/githubnemo/CompileDaemon
-
Generate Go binding for contract.
make init-contract
-
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>
-
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 Postgres & Adminer for Database
make up
-
Init database
make migrate up
Or execute SQL queries directly at
migrations/init.sql
-
Run app on local
make dev
The application will run on
PORT
has been defined in.env
.