Ethlance is the first job market platform built entirely on the Ethereum blockchain. Free to use forever!
Ethlance V.2 (Newlance)
*Ethlance Version 2 is Currently in Development and is subject to change before final release*
Development
Prerequisites
- Node.js >= 20.18.1 (it's defined in
.tool-versionsand asdf is a good way to install it) - Java JDK >= 18 (for Clojure)
- Babashka
- PostgreSQL (tested with 17.3)
- IPFS daemon
- Ethereum testnet (e.g. ganache)
Running the system
Clojure gets its missing dependencies automatically during compilation. Node.js dependencies need to be installed manually. There are 3 places for it:
- Testnet & smart contract node deps at the project root:
yarn install - UI node dependencies
cd ui && yarn install - Server node dependencies
cd server && yarn install
Also a database needs to exist (configured in config/server-config-dev.edn under :district/db key). Here's some SQL to do it (via the psql command)
CREATE DATABASE ethlance_new; CREATE USER ethlanceusernew WITH PASSWORD 'passnew'; GRANT ALL PRIVILEGES ON DATABASE ethlancenew TO ethlanceusernew; \c ethlance_new GRANT ALL ON SCHEMA public TO ethlanceuser_new; ALTER DATABASE ethlancenew OWNER TO ethlanceusernew; -- Optional
The database schema gets created automatically when server is started.
After this you can start all necessary services at once from the terminal with overmind start - the processes to be started are defined in Procfile - Overmind - TIP for development it's better to run the bb run-server separately because although shadow-cljs recompiles the code on file saves, the node process doesn't reload it and for that manual restart is required to reload the updated code.
Or you can start them one by one (check the Procfile for respective commands):
- Start IPFS
:ipfs config points to external node - Start ganache
bb testnet-dev - Migrate Solidity contracts to testnet:
npx truffle migrate --network ganache --reset - Start server build
bb watch-server - Start server (to serve the API)
bb run-server - Start UI build
bb watch-ui
6500
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/smartcontractsqa.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:
ETHLANCE_ENV=qa npx truffle compile(replacing the network with one suitable for the env)- This generates ABI JSON files under
<ethlance-root>/resources/public/contracts/build/ - Server app needs to access them during runtime:
[:smart-contracts :contracts-build-path] - UI (browser app) needs them available: should be served by Nginx (or your web server of choice)
http://d0x-vm:6500/contracts/build/TestToken.json
2. Server (/server)
To build Server (consists mainly of graphql API):
- The following ENV variables need to be set:
export ETHLANCE_ENV=qa
- Compile with
clj -A:dev:shadow-clj release dev-server
out/ethlanceserver.js (and accompanying ethlanceserver.js.map source map)
- Before running it the smart contract ABI JSON files need to be in a location defined in the EDN file
ETHLNCECONFIGPATHat EDN path[:smart-contracts :contracts-build-path]
Running server:
- 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 isETHLANCECONFIGPATH. - Also earlier the UI (browser app) config was baked into the compiled JS file for the UI. Now it gets served via
/configendpoint from a location pointed to ENV variableUICONFIGPATH(contents loaded at run time from the file system). Thus, starting the server:
export ETHLANCE_ENV=qa - export SERVERCONFIGPATH=/path/to/server-config-qa.edn - export UICONFIGPATH=/path/to/ui-config-qa.edn - node out/ethlance_server.js
3. Browser (/ui)
- The following ENV variables need to be set:
export ETHLANCE_ENV=qa
- Compile with
clj -A:dev:shadow-clj release dev-ui
<ethlance-root>/ui/resources/public/main.js
- To serve the web page, configure the web server to serve the files under
<ethlance-root>/ui/resources/public
- The web server must also serve the ABI JSON files generated in 1. Smart contracts
/contracts/build/<ABI JSON FILE>.json (e.g. /contracts/build/Ethlance.json)
Contributing
Anyone is welcome to contribute to the ethlance project, here are some brief guidelines:
- Make sure to squash your commits
- Reference issue numbers in your pull request
- Rebase your changes on upstream (
git remote add upstream
git pull --rebase upstream master)
- Make changes in a separate well-named branch in your forked repo
improve-readme
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.
- User arrives to the home page
- This takes the user to the sign-up page
- Employer (having first filled in employer data)
Ethlance#createJob is called and a new copy of Job contract gets deployed
- In case the employer invited arbiters during job creation
/jobs/new
tx-workflow-fns-server-repl/set-quote-for-arbitration
- Second: employer must accept the quote
+ ... where can they do it (one or more pages)?
+ script helper: tx-workflow-fns-server-repl/accept-quote-for-arbitration
- Employer can now invite candidates to participate in the new job
Job#addCandidate contract send
+ script helper: tx-workflow-fns-server-repl/add-candidate
- Candidate can search for available jobs
- Candidate chooses a job of interest from search results. To work on it, needs to send proposal
JobStory is created (DB model to track this user's interaction with this job)
- All users can view job contract page at
- Candidate can create invoices (for any of their jobs)
- Candidate can then raise dispute
- Employer can pay invoices