docker-compose

This commit is contained in:
Alexey 2019-07-18 17:45:33 +03:00
parent 28ba4bad50
commit 38e4f74afb
5 changed files with 23 additions and 10 deletions

@ -2,5 +2,3 @@ NET_ID=42
RPC_URL=https://kovan.infura.io/v3/a3f4d001c1fc4a359ea70dd27fd9cb51 RPC_URL=https://kovan.infura.io/v3/a3f4d001c1fc4a359ea70dd27fd9cb51
PRIVATE_KEY= PRIVATE_KEY=
MIXER_ADDRESS=0x30AF2e92263C5387A8A689322BbfE60b6B0855C4 MIXER_ADDRESS=0x30AF2e92263C5387A8A689322BbfE60b6B0855C4
DEFAULT_GAS_PRICE=1
GAS_ORACLE_URLS=https://www.etherchain.org/api/gasPriceOracle https://gasprice.poa.network/

@ -4,11 +4,14 @@
2. `cp .env.example .env` 2. `cp .env.example .env`
3. Modify `.env` as needed 3. Modify `.env` as needed
## Run ## Run localy
1. `npm run start` 1. `npm run start`
2. `curl -X POST -H 'content-type:application/json' --data '<PROOF>' http://127.0.0.1:8000/relay` 2. `curl -X POST -H 'content-type:application/json' --data '<PROOF>' http://127.0.0.1:8000/relay`
Relayer should return a transaction hash. Relayer should return a transaction hash.
## Run in Docker
1. `docker-compose up -d`
## Proof example ## Proof example
```json ```json
{ {

@ -5,6 +5,6 @@ module.exports = {
rpcUrl: process.env.RPC_URL || 'https://kovan.infura.io/v3/a3f4d001c1fc4a359ea70dd27fd9cb51', rpcUrl: process.env.RPC_URL || 'https://kovan.infura.io/v3/a3f4d001c1fc4a359ea70dd27fd9cb51',
privateKey: process.env.PRIVATE_KEY, privateKey: process.env.PRIVATE_KEY,
mixerAddress: process.env.MIXER_ADDRESS || '0x30AF2e92263C5387A8A689322BbfE60b6B0855C4', mixerAddress: process.env.MIXER_ADDRESS || '0x30AF2e92263C5387A8A689322BbfE60b6B0855C4',
defaultGasPrice: process.env.DEFAULT_GAS_PRICE || 1, defaultGasPrice: 1,
gasOracleUrls: process.env.GAS_ORACLE_URLS ? process.env.GAS_ORACLE_URLS.split(' ') : ['https://www.etherchain.org/api/gasPriceOracle', 'https://gasprice.poa.network/'] gasOracleUrls: ['https://www.etherchain.org/api/gasPriceOracle', 'https://gasprice.poa.network/']
} }

12
docker-compose.yml Normal file

@ -0,0 +1,12 @@
version: '2'
services:
relayer:
image: relayer
build: ./
restart: always
ports:
- 8000:8000
environment:
- NODE_ENV=production
env_file: ./.env

@ -1,13 +1,13 @@
const { fetchGasPrice, isValidProof } = require('./utils')
const { numberToHex, toWei, toHex } = require('web3-utils') const { numberToHex, toWei, toHex } = require('web3-utils')
const Web3 = require('web3')
const express = require('express') const express = require('express')
const app = express() const app = express()
app.use(express.json()) app.use(express.json())
const { netId, rpcUrl, privateKey, mixerAddress, defaultGasPrice } = require('./config') const { netId, rpcUrl, privateKey, mixerAddress, defaultGasPrice } = require('./config')
const { fetchGasPrice, isValidProof } = require('./utils')
const Web3 = require('web3')
const web3 = new Web3(rpcUrl, null, { transactionConfirmationBlocks: 1 }) const web3 = new Web3(rpcUrl, null, { transactionConfirmationBlocks: 1 })
const account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey) const account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey)
web3.eth.accounts.wallet.add('0x' + privateKey) web3.eth.accounts.wallet.add('0x' + privateKey)