Using web3 simulated

This commit is contained in:
Richard Ramos 2018-04-17 17:09:52 -04:00
parent 967a742bfd
commit 9432694fa3

View File

@ -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);
} }