项目作者: district0x

项目描述 :
A peer-to-peer marketplace for the exchange of names registered via the Ethereum Name Service
高级语言: JavaScript
项目地址: git://github.com/district0x/name-bazaar.git
创建时间: 2017-07-01T16:47:45Z
项目社区:https://github.com/district0x/name-bazaar

开源协议:Eclipse Public License 1.0

下载



District0x Discord server
LICENSE
pull requests welcome
Build Status


Name Bazaar

A peer-to-peer marketplace for the exchange of names registered via the Ethereum Name Service.

See at https://namebazaar.io

Smart-contracts can be found here.

Starting a dev server

In a terminal, start a ganache blockchain

  1. ./run-ganache.sh

Note that this uses docker and will try to pull trufflesuite/ganache-cli:v6.12.1 image if you don’t have it.

Alternatively, you can connect directly to one of ethereum testnet networks - e.g. goerli. In order to do this, specify correct smart contract addresses and :web3 properties in the ./config.edn file. Example config file can be found in docker-builds/server/config.example.edn.

Open another terminal, start a repl and build the dev server (with
figwheel repl)

  1. lein repl
  2. (start-server!)

Figwheel will prompt for a connection for the repl instance.

Open another terminal, run the compiled server script, which should
connect to the figwheel repl.

  1. node dev-server/name-bazaar.js

(If you have problems re-running this command, try removing dev-server
folder and try to start the server again)

Redeploy smart-contracts and generate mock data

You can (re)deploy contracts with

  1. truffle migrate --reset

and (optionally) generate some samle dev data from the clojurescript REPL by running the following command:

  1. (generate-data)

Redeployment / generation can take a long time, please be patient.

Start dev UI

If you wish to connect to the dev server discussed above, open a
separate terminal, and build the client-side ui

  1. lein repl
  2. (start-ui!)

You can then connect to the server through a web browser at http://localhost:4541

Semantic UI

To build the Semantic UI pieces of the app you need to have gulp installed.
Note that gulp 4.x does not work, you need a 3.x version.

npm install gulp@^3.9.0 --save

Then use our handy script:

./semantic.sh build
or
./semantic.sh watch

Depending upon how you’d like to work.

Start a development UI for client-side development only

If you’re only focusing on working with the UI, you can start a UI
interface which connects to the production server using mainnet.

  1. lein repl
  2. (start-ui! :ui-only? true)

In separate terminal, start the supplied docker nginx server

  1. docker-compose build nginx
  2. docker-compose up nginx
  3. # Visit website at http://localhost:3001

Note: using this client is using the main ethereum network, it is
ill-advised to carry out transactions unless you know what you are doing!

Backend (server) tests:

  1. lein doo node "server-tests"

(If you have problems running the tests, try to remove server-tests directory
and try re-running the tests again)

The doo runner will autobuild the test and re-run them as the watched files change.
Alternatively:

  1. lein cljsbuild once server-tests
  2. node server-tests/server-tests.js

Frontend (browser) tests:

To run browser tests use the following command:

  1. lein npm run cypress-open

Tests connect to a running app on http://localhost:4541. It is recommended to run the
tests with clear ganache network, otherwise the tests will be slower or fail.

Development env through nginx:

  1. docker-compose build nginx
  2. docker-compose up nginx

and start (start-ui!), (start-server!) as usual, but open the site on http://localhost:3001

Build for production

Following commands are used to build system for production

  1. lein build-prod-server
  2. lein build-prod-ui
  3. lein build-css
  4. # To build all 3 in parallel use
  5. lein build-prod
  6. # To run prod server
  7. node server/name-bazaar.js

Testnet deploy

To run server in docker container use image district0x/namebazaar-server, e.g.:

  1. docker run --name=namebazaar-server \
  2. --net=host \
  3. -v /path/to/config.edn:/configs/namebazaar.config.edn \
  4. district0x/namebazaar-server:latest

You can choose between tags dev, latest (intended for QA deploys) and release (intended for production deploy). As for the config file, you can find an example in docker-builds/server/config.example.edn. Of particular interest is providing correct addresses of smart contracts on the blockchain you’ll link the app to.

For UI use the district0x/namebazaar-ui image:

  1. docker run --name=namebazaar-ui \
  2. --net=host \
  3. district0x/namebazaar-ui:latest

Note that there is no passing of config file for UI: currently for any change of UI config you need to build a new image (see the next section). The hardcoded configuration is at src/name_bazaar/ui/config.cljs.

Deploying Name Bazaar smart contracts

First, you need to specify deployments secrets in config.edn. For example:

  1. {:truffle {:goerli {:privateKeys ["0x0000..."]
  2. :infuraKey "0000...."
  3. :ensAddress "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"
  4. :registrarAddress "0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85"
  5. :publicResolverAddress "0xE264d5bb84bA3b8061ADC38D3D76e6674aB91852"
  6. :reverseRegistrarAddress "0xD5610A08E370051a01fdfe4bB3ddf5270af1aA48"}}}

ENS address are not in documentation, but in some random post on forum https://discuss.ens.domains/t/deployment-of-new-contracts-inc-namewrapper-to-testnet-goerli/14505

Then, you can use truffle to deploy the contracts just by running the following command in bash:

  1. # you can also use `--network mainnet` - see truffle-config.js for deployment details for more information.
  2. truffle migrate --network goerli

Linting and formatting smart contracts

We use ethlint for linting solidity files. You
can use lein npm run ethlint and lein npm run ethlint-fix to run the linter.

You can use lein run-slither to run slither to
statically analyze the smart contracts. However, this tool reports many false positives.