Skip to content

Commit 0d1c40b

Browse files
authored
Merge pull request #301 from PolymathNetwork/CLI-minor-updates
CLI: Gas limit for estimation
2 parents deeb1fe + 12879cd commit 0d1c40b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

CLI/commands/common/common_functions.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ module.exports = {
5050
sendTransaction: async function (from, action, gasPrice, value, factor) {
5151
if (typeof factor === 'undefined') factor = 1.2;
5252

53+
let block = await web3.eth.getBlock("latest");
54+
let networkGasLimit = block.gasLimit;
55+
5356
let gas = Math.round(factor * (await action.estimateGas({ from: from.address, value: value})));
57+
if (gas > networkGasLimit) gas = networkGasLimit;
58+
5459
console.log(chalk.black.bgYellowBright(`---- Transaction executed: ${action._method.name} - Gas limit provided: ${gas} ----`));
5560

5661
let nonce = await web3.eth.getTransactionCount(from.address);

0 commit comments

Comments
 (0)