fee check
This commit is contained in:
parent
faecc9fa87
commit
3ec4b6c7ec
@ -2,3 +2,5 @@ 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
|
||||||
|
# in wei
|
||||||
|
DESIRED_FEE=10000000000000000
|
@ -4,7 +4,8 @@ module.exports = {
|
|||||||
netId: process.env.NET_ID || 42,
|
netId: process.env.NET_ID || 42,
|
||||||
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,
|
||||||
|
desiredFee: process.env.DESIRED_FEE || 10000000000000000, // 0.01 ETH
|
||||||
defaultGasPrice: 1,
|
defaultGasPrice: 1,
|
||||||
gasOracleUrls: ['https://www.etherchain.org/api/gasPriceOracle', 'https://gasprice.poa.network/']
|
gasOracleUrls: ['https://www.etherchain.org/api/gasPriceOracle', 'https://gasprice.poa.network/']
|
||||||
}
|
}
|
15
index.js
15
index.js
@ -1,16 +1,16 @@
|
|||||||
const { numberToHex, toWei, toHex } = require('web3-utils')
|
const { numberToHex, toWei, toHex, toBN } = require('web3-utils')
|
||||||
const Web3 = require('web3')
|
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())
|
||||||
app.use(function(req, res, next) {
|
app.use(function(req, res, next) {
|
||||||
res.header('Access-Control-Allow-Origin', '*') // update to match the domain you will make the request from
|
res.header('Access-Control-Allow-Origin', '*')
|
||||||
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept')
|
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept')
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
const { netId, rpcUrl, privateKey, mixerAddress, defaultGasPrice } = require('./config')
|
const { netId, rpcUrl, privateKey, mixerAddress, defaultGasPrice, desiredFee } = require('./config')
|
||||||
const { fetchGasPrice, isValidProof } = require('./utils')
|
const { fetchGasPrice, isValidProof } = require('./utils')
|
||||||
|
|
||||||
const web3 = new Web3(rpcUrl, null, { transactionConfirmationBlocks: 1 })
|
const web3 = new Web3(rpcUrl, null, { transactionConfirmationBlocks: 1 })
|
||||||
@ -36,10 +36,11 @@ app.post('/relay', async (req, resp) => {
|
|||||||
|
|
||||||
let { pi_a, pi_b, pi_c, publicSignals } = req.body
|
let { pi_a, pi_b, pi_c, publicSignals } = req.body
|
||||||
|
|
||||||
// TODO
|
const fee = toBN(publicSignals[3])
|
||||||
// if (bigInt(proof.publicSignals[3]) < getMinimumFee()) {
|
if (fee.lt(toBN(desiredFee))) {
|
||||||
// resp.status(403).send('Fee is too low')
|
console.log('Fee is too low')
|
||||||
// }
|
return resp.status(400).send('Fee is too low')
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const nullifier = publicSignals[1]
|
const nullifier = publicSignals[1]
|
||||||
|
Loading…
Reference in New Issue
Block a user