mirror of
https://github.com/status-im/snt-gas-relay.git
synced 2025-01-27 14:44:47 +00:00
Using web3 simulated
This commit is contained in:
parent
967a742bfd
commit
9432694fa3
@ -196,16 +196,17 @@ const processMessages = async function(error, message, subscription){
|
||||
}
|
||||
|
||||
// Estimate costs
|
||||
const web3Sim = new Web3(ganache.provider({fork: `${config.blockchain.protocol}://${config.blockchain.host}:${config.blockchain.port}`}));
|
||||
const simAccounts = await web3.eth.getAccounts();
|
||||
let simulatedReceipt = await web3.eth.sendTransaction({
|
||||
const web3Sim = new Web3(ganache.provider({fork: `http://localhost:8545`}));
|
||||
const simAccounts = await web3Sim.eth.getAccounts();
|
||||
let simulatedReceipt = await web3Sim.eth.sendTransaction({
|
||||
from: simAccounts[0],
|
||||
to: address,
|
||||
value: 0,
|
||||
data: payload
|
||||
});
|
||||
|
||||
const estimatedGas = web3.utils.toBN(simulatedReceipt.gasUsed);
|
||||
|
||||
console.log(simulatedReceipt);
|
||||
if(gasLimit.lt(estimatedGas)) {
|
||||
return reply("Gas limit below estimated gas", message);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user