/zbank_payroll

A payroll project for 2023 Internet Computer BUIDL Bitcoin Hackathon

Primary LanguageTypeScript

zbank_payroll

A crypto payroll back office built on the internet computer.

image

Prerequisites

  • Downloaded and installed Node.js.
  • Downloaded and installed Angular.
  • Downloaded and installed the DFINITY Canister SDK.
  • Downloaded Bitcoin Node
  • Remember to stop any Internet Computer or other network process that would create a port conflict on 4943.

Demo

Demo Video

Environment preparation

  1. Start Bitcoin local node

    ./bin/bitcoind -conf=$(pwd)/bitcoin.conf -datadir=$(pwd)/data --port=18444
  2. Start ICP local network

    dfx start --clean --background --enable-bitcoin

Deploy the project on ICP local network

  1. backend

    cargo update
    dfx deploy zbank_payroll_backend
  2. bitcoin

    dfx deploy zbank_bitcoin --argument '(variant { Regtest })'
  3. frontend (We use Angular to build)

    dfx generate zbank_bitcoin
    dfx generate zbank_payroll_backend
    cd src/canister/frontend
    npm install
    dfx canister create zbank_payroll_frontend
    ng build
    dfx deploy zbank_payroll_frontend

    You can also use ng serve to start frontend server without deploy on ICP.

Usefule Bitcoin commands

  1. mining

    ./bin/bitcoin-cli -conf=$(pwd)/bitcoin.conf generatetoaddress <number-of-blocks> <address>
  2. check mem pool

    ./bin/bitcoin-cli -conf=$(pwd)/bitcoin.conf getrawmempool
  3. Create wallet

    ./bin/bitcoin-cli -conf=$(pwd)/bitcoin.conf -regtest createwallet "<wallet_name>"
  4. Load wallet

    ./bin/bitcoin-cli -conf=$(pwd)/bitcoin.conf loadwallet "<wallet_name>"
  5. Unload wallet

    ./bin/bitcoin-cli -conf=$(pwd)/bitcoin.conf unloadwallet "<wallet_name>"
  6. Get new wallet address

    ./bin/bitcoin-cli -conf=$(pwd)/bitcoin.conf getnewaddress "<wallet_name>" "legacy"

Reset environment

  1. Clear Bitcoin local node

    rm -rf data/regtest/
  2. Clear ICP local network

    rm -rf .dfx

Trouble Shooting

Hint, If you're trying to send a transaction and the transaction isn't being mined, try sending the same transaction via bitcoin-cli.

./bin/bitcoin-cli -conf=$(pwd)/bitcoin.conf sendrawtransaction <tx-in-hex>
  1. bad-txns-premature-spend-of-coinbase: Coinbase is the inputless transaction created when a new block is mined and given to the miner, and must have 100 confirmations before that reward can be spent.

Todo

  • Make data persistent (preupgrade and postupgrade)
  • Deploy on ICP main network
  • Support other networks like ETH, TRON, etc.
  • Design business model to cover cycle costs
  • Add network fee and platform fee features
  • Add IAM(Identity Access Management) and RBAC(role-based access control)

Next Roadmap

  • Unsecured Loan: With transaction data on the payroll back office, we can provide credit rating for companies, and build the next product to link them with investors.