Fix: gas estimation
MODIFY
examples/transfer-ether.js
examples/transfer-ether.js
@@ -7,7 +7,7 @@ async function execute() {
matic.setWallet(utils.getPrivateKey())
const amount = new bn(10).pow(new bn(17)) // 0.1 token
- return matic.transferEther(process.env.FROM, amount, { from: process.env.FROM }) // performing a self-transfer
+ return matic.transferEther(process.env.FROM, amount, { from: process.env.FROM, parent: true }) // performing a self-transfer
}
execute().then(console.log) // eslint-disable-line

MODIFY
src/index.ts
src/index.ts
@@ -126,11 +126,14 @@ export default class Matic extends ContractsBase {
return this.transferERC20Tokens(maticWeth, to, value, options)
}
const web3Object = this.web3Client.getParentWeb3()
- const gas = await web3Object.eth.estimateGas({
+ if (!options.gas) {
+ options.gas = await web3Object.eth.estimateGas({
from,
value,
})
- Object.assign(options, { gas, value, to })
+ }
+
+ Object.assign(options, { value, to })
const _options = await this._fillOptions(options, {}, web3Object)
if (options.encodeAbi) {

Fix: gas estimation