• Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created almost 6 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

0x-launch-kit-frontend

โš ๏ธ Deprecation Warning ๏ธ๏ธโš ๏ธ

This project is no longer being actively maintained. To fork or run a Standard Relayer API instance, you can use the 0x API instead.

CircleCI dependencies Status devDependencies Status Coverage Status

This is an example implementation of a dApp that interacts with a 0x relayer. To use it, you need to have the URL of an existing relayer, or you can start one locally for use during development.

This version of Launch Kit supports 0x v3. If you're looking for v2 it is available on this branch.

This repo ships with both an ERC-20 token trading interface and an ERC-721 marketplace interface.

ERC-20 ERC-721

Usage

Clone this repository and install its dependencies:

git clone [email protected]:0xProject/0x-launch-kit-frontend.git
cd 0x-launch-kit-frontend
yarn

Using an existing relayer

If you have the URL of an existing relayer, you can use this frontend against it. After installing the dependencies, start the application with this command, replacing RELAYER_URL and RELAYER_WS_URL with the proper value:

REACT_APP_RELAYER_URL='https://RELAYER_URL/' REACT_APP_RELAYER_WS_URL='wss://RELAYER_URL/' yarn start

A browser tab will open in the http://localhost:3001 address. You'll need to connect MetaMask to the network used by the relayer.

You can optionally pass in any relayer endpoint that complies with the 0x Standard Relayer API. For example, if you want to show liquidity from 0x API:

REACT_APP_RELAYER_URL='https://api.0x.org/sra/v3' REACT_APP_RELAYER_WS_URL='wss://api.0x.org/sra/v3' REACT_APP_NETWORK_ID=1 REACT_APP_CHAIN_ID=1 yarn start

Creating a relayer for development

If you don't have a relayer, you can start one locally for development by running 0x-api directly, or by using docker-compose.
For docker-compose, first create a docker-compose.yml file like this:

version: '3'
services:
    ganache:
        image: 0xorg/ganache-cli
        ports:
            - '8545:8545'
    postgres:
        image: postgres:9.6
        environment:
            - POSTGRES_USER=api
            - POSTGRES_PASSWORD=api
            - POSTGRES_DB=api
        ports:
            - '5432:5432'
    backend:
        image: 0xorg/0x-api:latest
        depends_on:
            - postgres
            - mesh
        environment:
            CHAIN_ID: '1337'
            WHITELIST_ALL_TOKENS: 'true'
            FEE_RECIPIENT: '0x0000000000000000000000000000000000000001'
            MAKER_FEE_UNIT_AMOUNT: '0'
            TAKER_FEE_UNIT_AMOUNT: '0'
            MESH_WEBSOCKET_URI: 'ws://mesh:60557'
            MESH_HTTP_URI: 'http://mesh:60556'
            POSTGRES_URI: 'postgresql://api:api@postgres/api'
            ETHEREUM_RPC_URL: 'http://ganache:8545'
        ports:
            - '3000:3000'
    mesh:
        image: 0xorg/mesh:9.0.1
        depends_on:
            - ganache
        environment:
            ETHEREUM_RPC_URL: 'http://ganache:8545'
            ETHEREUM_CHAIN_ID: 1337
            VERBOSITY: 3
            WS_RPC_ADDR: '0.0.0.0:60557'
            HTTP_RPC_ADDR: '0.0.0.0:60556'
            # You can decrease the BLOCK_POLLING_INTERVAL for test networks to
            # improve performance. See https://0x-org.gitbook.io/mesh/ for more
            # Documentation about Mesh and its environment variables.
            BLOCK_POLLING_INTERVAL: '5s'
        ports:
            - '60556:60556'
            - '60557:60557'
            - '60558:60558'
            - '60559:60559'

and then run docker-compose up. This will create four containers: one is a Postgres database, one has a ganache with the 0x contracts deployed and some test tokens, another one has an instance of 0x-api implementation of a relayer that connects to that ganache and finally a container for 0x-mesh for order sharing and discovery on a p2p network.

After starting those containers, you can run the following in another terminal. A browser tab will open in the http://localhost:3001 address. You'll need to connect MetaMask to localhost:8545.

REACT_APP_RELAYER_URL='http://localhost:3000/sra/v3' REACT_APP_RELAYER_WS_URL='ws://localhost:3000/sra/v3' yarn start

Note: the state of the relayer will be kept between runs. If you want to start from scratch, use docker-compose up --force-recreate

Environment variables

You can create a .env file to set environment variables and configure the behavior of the dApp. Start by copying the example file (cp .env.example .env) and modify the ones you want. Some things you can configure are:

  • REACT_APP_RELAYER_URL: The URL of the relayer used by the dApp. Defaults to http://localhost:3000/v3
  • REACT_APP_RELAYER_WS_URL: The Websocket URL of the relayer used by the dApp. Defaults to http://localhost:3000/
  • REACT_APP_FEE_PERCENTAGE: The fee percentage amount charged on 0x orders filled via the Forwarder. Note this is limited to */WETH orders for the taker.
  • REACT_APP_FEE_RECIPIENT: The address which receives the fees from the Forwarder.
  • REACT_APP_NETWORK_ID: The network id to build the front end for. E.g 42 for Kovan, 50 for Ganache
  • REACT_APP_CHAIN_ID: The chain id to build the front end for. E.g 42 for Kovan, 1337 for Ganache
  • REACT_APP_DEFAULT_ORDER_EXPIRY_SECONDS: The expiration time for an order. Defaults to 1 day.

Check .env.example for the full list.

Using custom themes

If you want to add your own theme for the app, please read the THEMES.md file

More Repositories

1

0x-monorepo

0x protocol monorepo - includes our smart contracts and many developer tools
TypeScript
1,412
star
2

OpenZKP

OpenZKP - pure Rust implementations of Zero-Knowledge Proof systems.
Rust
646
star
3

0x-launch-kit

Start an exchange in under a minute
JavaScript
380
star
4

protocol

TypeScript
362
star
5

0x-api

An HTTP Interface to 0x liquidity and tooling
TypeScript
362
star
6

0x-mesh

A peer-to-peer network for sharing 0x orders
Go
258
star
7

0x-starter-project

A project showcasing how to get started with 0x.js
TypeScript
200
star
8

0x-launch-kit-backend

Launch a 0x relayer in under a minute [DEPRECATED]
TypeScript
173
star
9

standard-relayer-api

Standard specifications for 0x relayer public APIs
164
star
10

0x-protocol-specification

Specification for 0x protocol
148
star
11

tools

TypeScript
96
star
12

ZEIPs

0x Improvement Proposals
91
star
13

swap-demo-tutorial

JavaScript
67
star
14

website

0x.org website
TypeScript
54
star
15

0x-nextjs-demo-app

Example ERC20 swapping app made with 0x Swap API, Next.js, and ConnectKit
TypeScript
52
star
16

rpc-gateway

A failover proxy for node providers
Go
47
star
17

0x-relayer-registry

A collection of relayers using 0x
TypeScript
43
star
18

whitepaper

Technical document that specifies 0x protocol.
TeX
33
star
19

0x-parser

๐Ÿงพ A library that parses 0x transactions from EVM blockchains into a format that is user-friendly and easy to understand.
TypeScript
30
star
20

web3-typescript-typings

[DEPRECATED] A preliminary Web3 v0.x typescript type definition
30
star
21

dev-tools-truffle-example

An example Truffle project showing how to use the 0x Dev Tools with the Truffle framework
JavaScript
28
star
22

fast-abi

ABI encoding, fast
Rust
27
star
23

0x-event-pipeline

A node.js app for pulling 0x event info to inform things like staking.
TypeScript
26
star
24

0x-examples

A collection of 0x API code examples
TypeScript
19
star
25

VDF

A Solidity implementation of a VDF verifier contract
Solidity
16
star
26

0x-sdk

TypeScript SDK for building exchange functionality on Ethereum and EVM-compatible chains ๐Ÿ› .
TypeScript
15
star
27

0x-codesandbox

0x Codesandbox
TypeScript
14
star
28

0x-debug

TypeScript
14
star
29

quote-server

An RFQ quote server that can be used to provide quotes via 0x API
TypeScript
14
star
30

0x-settler

0x settlement contracts using Permit2
Solidity
11
star
31

0x-instant

JavaScript
10
star
32

0x-staking-pool-registry

A collection of metadata about staking pools on 0x - https://0x.org/
TypeScript
10
star
33

connect-starter-project

A tutorial for interacting with a relayer that conforms to the standard relayer API
TypeScript
10
star
34

0x-coordinator-server

A reference implementation of a 0x coordinator server (soft-cancel variant)
TypeScript
9
star
35

sutro

Eye of Sutro: Ethereum State Watcher
Rust
7
star
36

pm

6
star
37

branding

Logos and other media
5
star
38

p2p_incentives

Python
5
star
39

node-anvil

Nodejs bindings to Foundry Anvil
Rust
5
star
40

zrx-buyer

A demonstration of using asset-buyer to buy ZRX
TypeScript
4
star
41

0x-subgraph

TypeScript
4
star
42

mesh-viz

https://mesh-viz.0x.org/
TypeScript
4
star
43

matcha-flagged-tokens

4
star
44

0x-exchange-proxy-subgraph

TypeScript
4
star
45

0x-api-forked-testnet-example

A basic example for how you can test 0x API using a private for of Ethereum mainnet
TypeScript
4
star
46

proxy

Simple Go Proxy
Go
3
star
47

mesh-mock-graphql-api

Demo of the new Mesh GraphQL API using mock data
TypeScript
3
star
48

setup-helm

Github Action for Helm installation
TypeScript
3
star
49

mesh-workshop-demo

TypeScript
3
star
50

exchange-v3

TypeScript
2
star
51

0x-mesh-demo-client-javascript

[DEPRECATED] A demo 0x Mesh WebSocket client written in Javascript
TypeScript
2
star
52

ts-doc-gen

A CLI for generating a single MD reference doc file for a TS project
TypeScript
2
star
53

setup-govulncheck

Setup govulncheck: https://go.dev/security/vuln/
TypeScript
2
star
54

setup-foundry

Install foundry-rs/foundry in your Github Action workflow
TypeScript
2
star
55

mesh-rs

Rust implementation of the 0x Mesh protocol
Rust
1
star
56

matcha-unsupported-tokens

1
star
57

permit2-matcha

A headless prototype of how the Matcha API works with permit2 smart contracts.
TypeScript
1
star