Home

Awesome

Ethlance V.2 (Newlance)

CircleCI

Ethlance Version 2 is Currently in Development and is subject to change before final release

Development

Prerequisites

  1. Node.js >= 16.15.1
  2. Java JDK >= 18 (for Clojure)
  3. Babashka
  4. PostgreSQL (tested with 14.6)
  5. IPFS daemon
  6. Ethereum testnet (e.g. ganache)

Running the system

  1. Start IPFS
  2. Start ganache
  3. Migrate Solidity contracts to testnet: npx truffle migrate --network ganache --reset
  4. Start server build bb watch-server
  5. Start server (to serve the API) bb run-server
  6. Start UI build bb watch-ui

First steps, showing example data

In order for the front-end to be able to have the JWT token (kept in LocalStorage), you must sign a transaction. Currently it can be done manually. Open REPL for UI:

lein repl :connect 54200
(shadow/repl :dev-ui)
(in-ns 'ethlance.ui.event.sign-in)
(re/dispatch [:user/sign-in])

Then to generate some example data you can use server REPL:

lein repl :connect 54100
(shadow/repl :dev-server)
(in-ns 'tests.graphql.generator)
(generate-for-address "0xafcf1a2bc71acf041c93012a2e552e31026dfeab")

Tips & troubleshooting

Postgres setup

Start postgres console psql -d postgres

CREATE USER ethlanceuser WITH ENCRYPTED PASSWORD 'pass';
CREATE DATABASE ethlance WITH OWNER ethlanceuser;
-- alternatively if you created the database earlier, give access with:
GRANT ALL PRIVILEGES On ethlance TO ethlanceuser;

IPFS Server

Might require additional configuration for CORS if IPFS is running on a different host

ipfs config --json Gateway.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST", "OPTIONS"]'
ipfs config --json Gateway.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
ipfs config --json Gateway.HTTPHeaders.Access-Control-Allow-Headers '["X-Requested-With"]'
ipfs config --json Gateway.Writable true

Building & deployment

1. Smart contracts

The ethlance smart contracts should (for now) be deployed manually. As a result of the compilation process, the environment specific clojure files with contract addresses get written (e.g. shared/src/ethlance/shared/smart_contracts_qa.cljs for QA) and must be committed to git to make them available for deployment of browser & server applications.

During clojure application deployment (browser, server), the contracts must only be compiled, which will generate JSON ABI files under <ethlance-root>/resources/public/contracts/build/

Compilation:

  1. ETHLANCE_ENV=qa npx truffle compile (replacing the network with one suitable for the env)
  2. This generates ABI JSON files under <ethlance-root>/resources/public/contracts/build/
  3. Server app needs to access them during runtime:
  1. UI (browser app) needs them available: should be served by Nginx (or your web server of choice)

2. Server (<ethlance-root>/server)

To build Server (consists mainly of graphql API):

  1. The following ENV variables need to be set:
  1. Compile with clj -A:dev:shadow-clj release dev-server
  1. Before running it the smart contract ABI JSON files need to be in a location defined in the EDN file ETHLNCE_CONFIG_PATH at EDN path [:smart-contracts :contracts-build-path]

Running server:

  1. Earlier the server config was compiled into the generated JS file. Now it will be loaded during runtime (at application startup) from the variable specified under :config :env-name. As for now it is ETHLANCE_CONFIG_PATH.
  2. Also earlier the UI (browser app) config was baked into the compiled JS file for the UI. Now it gets served via /config endpoint from a location pointed to ENV variable UI_CONFIG_PATH (contents loaded at run time from the file system). Thus, starting the server:

3. Browser (<ethlance-root>/ui)

  1. The following ENV variables need to be set:
  1. Compile with clj -A:dev:shadow-clj release dev-ui
  1. To serve the web page, configure the web server to serve the files under <ethlance-root>/ui/resources/public
  1. The web server must also serve the ABI JSON files generated in 1. Smart contracts

Contributing

Anyone is welcome to contribute to the ethlance project, here are some brief guidelines:

Overview of workflows

Here's a brief overview of the sequence of actions that different user types can take to create, find and arbiter jobs.

  1. User arrives to the home page
  1. This takes the user to the sign-up page
  1. Employer (having first filled in employer data)
  1. In case the employer invited arbiters during job creation /jobs/new
  1. Employer can now invite candidates to participate in the new job
  1. Candidate can search for available jobs
  1. Candidate chooses a job of interest from search results. To work on it, needs to send proposal
  1. All users can view job contract page at
  1. Candidate can create invoices (for any of their jobs)
  1. Candidate can then raise dispute
  1. Employer can pay invoices