Added gas estimation

This commit is contained in:
Richard Ramos 2018-06-27 14:44:37 -04:00
parent b96ecd5a20
commit 5e9a0da95c
1 changed files with 9 additions and 6 deletions

View File

@ -102,17 +102,20 @@ const AddPoll = withFormik({
const { addPoll } = PollManager.methods;
const currentBlock = await getBlockNumber();
const endTime = currentBlock + (oneDayinBlocks * 90);
addPoll(
endTime,
singleChoiceDef(description, ['YES', 'NO'])
)
.send()
const toSend = addPoll(endTime, singleChoiceDef(description, ['YES']));
toSend.estimateGas()
.then(gasEstimated => {
console.log("addPoll gas estimated: "+gasEstimated);
return toSend.send({gas: gasEstimated + 1000});
})
.then(res => {
console.log('sucess:', res);
})
.catch(res => {
console.log('fail:', res);
})
});
}
})(StyledForm)