Added gas estimation

This commit is contained in:
Richard Ramos 2018-06-27 14:44:37 -04:00
parent b96ecd5a20
commit 5e9a0da95c

View File

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