mirror of
https://github.com/status-im/snt-gas-relay.git
synced 2025-02-05 19:13:39 +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
|
// Estimate costs
|
||||||
const web3Sim = new Web3(ganache.provider({fork: `${config.blockchain.protocol}://${config.blockchain.host}:${config.blockchain.port}`}));
|
const web3Sim = new Web3(ganache.provider({fork: `http://localhost:8545`}));
|
||||||
const simAccounts = await web3.eth.getAccounts();
|
const simAccounts = await web3Sim.eth.getAccounts();
|
||||||
let simulatedReceipt = await web3.eth.sendTransaction({
|
let simulatedReceipt = await web3Sim.eth.sendTransaction({
|
||||||
from: simAccounts[0],
|
from: simAccounts[0],
|
||||||
to: address,
|
to: address,
|
||||||
value: 0,
|
value: 0,
|
||||||
data: payload
|
data: payload
|
||||||
});
|
});
|
||||||
const estimatedGas = web3.utils.toBN(simulatedReceipt.gasUsed);
|
|
||||||
|
|
||||||
|
const estimatedGas = web3.utils.toBN(simulatedReceipt.gasUsed);
|
||||||
|
console.log(simulatedReceipt);
|
||||||
if(gasLimit.lt(estimatedGas)) {
|
if(gasLimit.lt(estimatedGas)) {
|
||||||
return reply("Gas limit below estimated gas", message);
|
return reply("Gas limit below estimated gas", message);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user