Skip to content

Commit

Permalink
Improve and simplify the estimation gas.
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasMahe committed Apr 23, 2019
1 parent 308c253 commit 9e9c71d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions systemservices/marketplace/src/contracts/utils.ts
Expand Up @@ -53,14 +53,15 @@ const createTransactionTemplate = (
chainID: chainID,
to: contract.options.address,
value: '0',
data: data
}
return {
...tx,
nonce: (await web3.eth.getTransactionCount(inputs.from)) + (shiftNonce || 0),
data: data,
gas: inputs.gas,
gasPrice: inputs.gasPrice || defaultGasPrice,
gas: inputs.gas || await web3.eth.estimateGas({...tx, from: inputs.from})
nonce: (await web3.eth.getTransactionCount(inputs.from)) + (shiftNonce || 0),
}
if (!tx.gas) {
tx.gas = await web3.eth.estimateGas({...tx, from: inputs.from})
}
return tx
}

const extractEventFromLogs = (web3: Web3, contract: Contract, eventName: string, logs: Log[]): any => {
Expand Down

0 comments on commit 9e9c71d

Please sign in to comment.