Skip to content
Permalink
Browse files

Merge pull request #6 from tomochain/features/tomochain-testnet-integ…

…ration

Features/tomochain testnet integration
  • Loading branch information...
piavgh committed Feb 25, 2019
2 parents df458fa + f3384d2 commit fc51ca9a437ade14eb5e936a8a7b80037564be96
@@ -1,3 +1,5 @@
TOMO__MAINNET_PRIVATE_KEY=3411b45169aa5a8312e51357db68621031020dcf46011d7431db1bbb6d3922ce
TOMO__RINKEBY_PRIVATE_KEY=3411b45169aa5a8312e51357db68621031020dcf46011d7431db1bbb6d3922ce
TOMO__LOCAL_PRIVATE_KEY=7f4c1bacba63f05827f6d8fc0e22cf68c42005775a7f73abff7d819986bae77c
ETHEREUM_MNEMONIC=Your Ethereum mnemonic here
ROPSTEN_MNEMONIC=Your Ropsten mnemonic here
RINKEBY_MNEMONIC=Your Rinkeby mnemonic here
TOMOCHAIN_MNEMONIC=Your Tomochain mainnet mnemonic here
TOMOCHAIN_TESTNET_MNEMONIC=Your Tomochain testnet mnemonic here
@@ -4,39 +4,15 @@
https://golang.org/doc/install
```

0.2. Install go-ethereum from source code
0.2. Download go-ethereum source code
```
https://geth.ethereum.org/install/#build-it-from-source-code
```
----------------
## II. dex-protocol
1. Clone it:
```
git clone git@github.com:tomochain/dex-protocol.git
```
2. Install necessary golang packages:
```
yarn install-requirements
```
3.
```
cd OrderBook
mkdir $GOPATH/src/github.com/tomochain
ln -sF $PWD $GOPATH/src/github.com/tomochain/orderbook
```
4. Reset go-ethereum repository to a specific commit in order to work (temporary):
```
cd $GOPATH/src/github.com/ethereum/go-ethereum
git reset --hard 880de230b44e20282abdef0f1f9a3294ce68e5d8
```
5. By default, we use POA consensus for demo
Assume you are in `dex-protocol` folder:
```
Run Node1: `yarn node1 -mining true`
Run Node2: `yarn node2 -mining true`
Run Backend: `yarn backend` (optional)
```
----------------
## II. Blockchain

You can use Ganache for development or the testnet of your own

## III. dex-smart-contract
1. Clone it:
```
@@ -46,38 +22,32 @@ git clone git@github.com:tomochain/dex-smart-contract.git
```
yarn global add truffle
```
3. Run `yarn`
4. Deploy contracts to blockchain:
3. Run `yarn install`

4. Update .env file with your mnemonic words (You can check file `.env.sample` for more information)

5. Deploy smart contracts to blockchain:
```
yarn deploy-contracts
```
This command will deploy smart contract to your local blockchain (--network development)

OR

----------------
## IV. dex-client
1. Clone it:
```
git clone git@github.com:tomochain/dex-client.git
```
2. Install dependencies
```
yarn
```
3. Install `sass`:
```
https://sass-lang.com/install
```
4. Copy token addresses into file `src/config/addresses.json`:
```
yarn query-tokens
truffle migrate --network tomochainTestnet
```
5. Start the development server
This command will deploy smart contract to Tomochain Testnet

OR

```
yarn start
truffle migrate --network tomochain
```
This command will also compile sass files
This command will deploy smart contract to Tomochain Mainnet (but don't use for now)

----------------
## V. dex-server
## IV. dex-server
1. Clone it:
```
git clone git@github.com:tomochain/dex-server.git
@@ -87,11 +57,7 @@ git clone git@github.com:tomochain/dex-server.git
```
yarn install-requirements
```
4. Go to `dex-server` directory, run this command:
```
ln -sF $PWD $GOPATH/src/github.com/tomochain/backend-matching-engine
```
5. Run docker environment
4. Run docker environment
```
yarn start-env
```
@@ -100,6 +66,14 @@ OR
yarn reset-env
```
in case you want to reset MongoDB, Redis, RabbitMQ data

5. Update file `seed-data.sh`
```
Update line 2. NETWORK="development" with your network of choice
It can be "development", "tomochainTestnet" or "tomochain"
```

6. Generate seed and import seed data into mongo
```
yarn seeds
@@ -110,24 +84,28 @@ yarn start
```

----------------
# DONE

## Reset in case something went wrong
1. Manually delete 2 folders `.data_30100` and `.data_30101` inside folder `dex-protocol` (these 2 folders are hidden)
## V. dex-client
1. Clone it:
```
cd dex-protocol
rm -rf .data_*
git clone git@github.com:tomochain/dex-client.git
```
2. Do everything from point II. dex-protocol except some commands such as:
2. Install dependencies
```
git clone ...
yarn
```
3. Install `sass`:
```
ln -sF ...
https://sass-lang.com/install
```
4. Copy token addresses into file `src/config/addresses.json`:
```
git reset ...
yarn query-tokens
```
5. Start the development server
```
yarn install-requirements
yarn start
```
This command will also compile sass files

----------------
## DONE

This file was deleted.

Oops, something went wrong.
@@ -1,9 +1,14 @@
require('dotenv').config()

const contractAddresses = require('./contractAddresses.json')
const NETWORK_ID = {
ETHEREUM: '1',
ROPSTEN: '3',
RINKEBY: '4',
TOMOCHAIN: '88',
TOMOCHAIN_TESTNET: '89',
DEVELOPMENT: '8888',
}

// const quoteTokens = ['WETH', 'DAI', 'TUSD', 'USDC'];
const quoteTokens = []
const baseTokens = [
'ETH',
// 'AE',
@@ -24,40 +29,14 @@ const baseTokens = [
// 'ZRX',
]

const decimals = {
AE: 18,
BAT: 18,
BNB: 18,
DAI: 18,
GNT: 18,
KNC: 18,
LOOM: 18,
LRC: 18,
MITH: 18,
MKR: 18,
NPXS: 18,
OMG: 18,
PRFT: 18,
REP: 18,
SNT: 18,
WETH: 18,
WTC: 18,
ZRX: 18,
TUSD: 18,
USDC: 6,
}
// const quoteTokens = ['WETH', 'DAI', 'TUSD', 'USDC'];
const quoteTokens = []

const rewardAddresses = {
'1': '',
'8888': '0xD3050147F1AC4c552941930C7b27386dE8A710b8',
}

const keys = {
'1': (process.env.TOMO_MAINNET_KEYS || '').split(','),
'4': (process.env.TOMO_RINKEBY_KEYS || '').split(','),
'8888': [],
}

let tokenContracts = null
const getTokenContracts = (artifacts, filters) => {
if (tokenContracts === null) {
@@ -95,30 +74,42 @@ const getTokenContracts = (artifacts, filters) => {
}

module.exports = {
NETWORK_ID,
quoteTokens,
baseTokens,
tokens: [...baseTokens, ...quoteTokens],
decimals,
rewardAddresses,
contractAddresses,
keys,
// truffle config
infura: {
ethereum: 'https://mainnet.infura.io/Oi27hEUIuGqMsrYGpI7e',
ropsten: 'https://ropsten.infura.io/Oi27hEUIuGqMsrYGpI7e',
rinkeby: 'https://rinkeby.infura.io/Oi27hEUIuGqMsrYGpI7e',
kovan: 'https://kovan.infura.io/Oi27hEUIuGqMsrYGpI7e',
rpcEndpoints: {
ethereum: 'https://mainnet.infura.io/v3/ebaf1785cc1b4f319e0ff07f26cadae8',
ropsten: 'https://ropsten.infura.io/v3/ebaf1785cc1b4f319e0ff07f26cadae8',
kovan: 'https://ropsten.infura.io/v3/ebaf1785cc1b4f319e0ff07f26cadae8',
rinkeby: 'https://rinkeby.infura.io/v3/ebaf1785cc1b4f319e0ff07f26cadae8',
tomochain: 'https://rpc.tomochain.com',
tomochainTestnet: 'https://testnet.tomochain.com',
},
constants: {
DEFAULT_GAS: 4.5 * 10 ** 6,
MAX_GAS: 6.0 * 10 ** 6,
DEFAULT_LOW_GAS_PRICE: 0.1 * 10 ** 9,
DEFAULT_GAS_PRICE: 15 * 10 ** 9,
DEFAULT_HIGH_GAS_PRICE: 9 * 10 ** 9,
TOKENS_ALLOCATED_TO_PROOF: 1181031 * 10 ** 18,
DECIMALS_POINTS: 10 ** 18,
TOKEN_UNITS: 10 ** 18,
ETHER: 10 ** 18,
development: {
DEFAULT_GAS: 4.5 * 10 ** 6,
MAX_GAS: 6.0 * 10 ** 6,
DEFAULT_LOW_GAS_PRICE: 0.1 * 10 ** 9,
DEFAULT_GAS_PRICE: 15 * 10 ** 9,
DEFAULT_HIGH_GAS_PRICE: 9 * 10 ** 9,
},
tomochain: {
DEFAULT_GAS: 4.5 * 10 ** 6,
MAX_GAS: 20 * 10 ** 6,
DEFAULT_LOW_GAS_PRICE: 0.1 * 10 ** 9,
DEFAULT_GAS_PRICE: 10 ** 14,
DEFAULT_HIGH_GAS_PRICE: 9 * 10 ** 9,
},
tomochainTestnet: {
DEFAULT_GAS: 4.5 * 10 ** 6,
MAX_GAS: 20 * 10 ** 6,
DEFAULT_LOW_GAS_PRICE: 0.1 * 10 ** 9,
DEFAULT_GAS_PRICE: 10 ** 14,
DEFAULT_HIGH_GAS_PRICE: 9 * 10 ** 9,
},
},
accounts: {
marketMaker: [
@@ -128,9 +119,9 @@ module.exports = {
'0xF069080F7acB9a6705b4a51F84d9aDc67b921bDF',
'0x657B4CbA193CCac878a3561F36329Facd6D19825',
],
rinkeby: [],
ropsten: [],
ethereum: [],
ropsten: [],
rinkeby: [],
},
getTokenContracts,
}
@@ -0,0 +1,19 @@
const config = {
ethereum: {
mnemonic: process.env.ETHEREUM_MNEMONIC,
},
ropsten: {
mnemonic: process.env.ROPSTEN_MNEMONIC,
},
rinkeby: {
mnemonic: process.env.RINKEBY_MNEMONIC,
},
tomochain: {
mnemonic: process.env.TOMOCHAIN_MNEMONIC,
},
tomochainTestnet: {
mnemonic: process.env.TOMOCHAIN_TESTNET_MNEMONIC,
},
}

module.exports = config
@@ -12,7 +12,6 @@
"dev": "webpack-dev-server",
"test": "truffle migrate --reset && truffle test",
"deploy-contracts": "truffle migrate --network development -f 1 --to 3",
"generate-exchange-go": "node scripts/generateExchangeGo.js ../dex-server/contracts/contractsinterfaces/exchange.go",
"watch": "npm-watch"
},
"watch": {
@@ -55,7 +54,6 @@
"webpack-dev-server": "^2.3.0"
},
"dependencies": {
"@digix/truffle-lightwallet-provider": "~0.1.4",
"babel-plugin-transform-class-properties": "~6.24.1",
"babel-preset-react": "~6.24.1",
"babel-preset-stage-3": "~6.24.1",
@@ -64,6 +62,7 @@
"chai-bignumber": "~2.0.2",
"dotenv": "~5.0.1",
"npm-watch": "~0.3.0",
"truffle-hdwallet-provider": "^1.0.4",
"web3": "~1.0.0-beta.34",
"web3-eth-accounts": "~1.0.0-beta.34"
}

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit fc51ca9

Please sign in to comment.
You can’t perform that action at this time.