mirror of
https://github.com/tornadocash/tornado-relayer
synced 2024-02-02 15:04:06 +01:00
Switch config to .env
This commit is contained in:
parent
f7bca08480
commit
28ba4bad50
6
.env.example
Normal file
6
.env.example
Normal file
@ -0,0 +1,6 @@
|
||||
NET_ID=42
|
||||
RPC_URL=https://kovan.infura.io/v3/a3f4d001c1fc4a359ea70dd27fd9cb51
|
||||
PRIVATE_KEY=
|
||||
MIXER_ADDRESS=0x30AF2e92263C5387A8A689322BbfE60b6B0855C4
|
||||
DEFAULT_GAS_PRICE=1
|
||||
GAS_ORACLE_URLS=https://www.etherchain.org/api/gasPriceOracle https://gasprice.poa.network/
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,4 +1,3 @@
|
||||
.vscode
|
||||
node_modules/
|
||||
env.json
|
||||
|
||||
.env
|
@ -1,11 +1,11 @@
|
||||
# Relayer for Tornado mixer
|
||||
## Setup
|
||||
1. `npm i`
|
||||
2. `cp env.json.example env.json`
|
||||
3. Modify `env.json` as needed
|
||||
2. `cp .env.example .env`
|
||||
3. Modify `.env` as needed
|
||||
|
||||
## Run
|
||||
1. `node index.js`
|
||||
1. `npm run start`
|
||||
2. `curl -X POST -H 'content-type:application/json' --data '<PROOF>' http://127.0.0.1:8000/relay`
|
||||
Relayer should return a transaction hash.
|
||||
|
||||
|
10
config.js
Normal file
10
config.js
Normal file
@ -0,0 +1,10 @@
|
||||
require('dotenv').config()
|
||||
|
||||
module.exports = {
|
||||
netId: process.env.NET_ID || 42,
|
||||
rpcUrl: process.env.RPC_URL || 'https://kovan.infura.io/v3/a3f4d001c1fc4a359ea70dd27fd9cb51',
|
||||
privateKey: process.env.PRIVATE_KEY,
|
||||
mixerAddress: process.env.MIXER_ADDRESS || '0x30AF2e92263C5387A8A689322BbfE60b6B0855C4',
|
||||
defaultGasPrice: process.env.DEFAULT_GAS_PRICE || 1,
|
||||
gasOracleUrls: process.env.GAS_ORACLE_URLS ? process.env.GAS_ORACLE_URLS.split(' ') : ['https://www.etherchain.org/api/gasPriceOracle', 'https://gasprice.poa.network/']
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"netId": 42,
|
||||
"rpcUrl": "https://kovan.infura.io/v3/a3f4d001c1fc4a359ea70dd27fd9cb51",
|
||||
"privateKey": "",
|
||||
"mixerAddress": "0x30AF2e92263C5387A8A689322BbfE60b6B0855C4",
|
||||
"defaultGasPrice": 1,
|
||||
"gasOracleUrls": [
|
||||
"https://www.etherchain.org/api/gasPriceOracle",
|
||||
"https://gasprice.poa.network/"
|
||||
]
|
||||
}
|
2
index.js
2
index.js
@ -5,7 +5,7 @@ const express = require('express')
|
||||
const app = express()
|
||||
app.use(express.json())
|
||||
|
||||
const { netId, rpcUrl, privateKey, mixerAddress, defaultGasPrice } = require('./env.json')
|
||||
const { netId, rpcUrl, privateKey, mixerAddress, defaultGasPrice } = require('./config')
|
||||
|
||||
const Web3 = require('web3')
|
||||
const web3 = new Web3(rpcUrl, null, { transactionConfirmationBlocks: 1 })
|
||||
|
5
package-lock.json
generated
5
package-lock.json
generated
@ -960,6 +960,11 @@
|
||||
"resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz",
|
||||
"integrity": "sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg="
|
||||
},
|
||||
"dotenv": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.0.0.tgz",
|
||||
"integrity": "sha512-30xVGqjLjiUOArT4+M5q9sYdvuR4riM6yK9wMcas9Vbp6zZa+ocC9dp6QoftuhTPhFAiLK/0C5Ni2nou/Bk8lg=="
|
||||
},
|
||||
"drbg.js": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz",
|
||||
|
@ -11,6 +11,7 @@
|
||||
"author": "Alexey Pertsev <alexey@peppersec.com> (https://peppersec.com)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dotenv": "^8.0.0",
|
||||
"express": "^4.17.1",
|
||||
"node-fetch": "^2.6.0",
|
||||
"web3": "^1.0.0-beta.55",
|
||||
|
2
utils.js
2
utils.js
@ -1,6 +1,6 @@
|
||||
const fetch = require('node-fetch')
|
||||
const { isHexStrict } = require('web3-utils')
|
||||
const { gasOracleUrls } = require('./env.json')
|
||||
const { gasOracleUrls } = require('./config')
|
||||
|
||||
async function fetchGasPrice({ gasPrices, oracleIndex = 0 }) {
|
||||
oracleIndex = (oracleIndex + 1) % gasOracleUrls.length
|
||||
|
Loading…
Reference in New Issue
Block a user