accounts/abi/bind: fix gas price suggestion with pre EIP-1559 clients (#23102)

This fixes transaction sending in the case where an app using go-ethereum v1.10.4
is talking to a pre-EIP-1559 RPC node. In this case, the eth_maxPriorityFeePerGas
endpoint is not available and we can only rely on eth_gasPrice.
pull/23129/head
Pierre R 3 years ago committed by GitHub
parent 35dbf7a8a3
commit 61f4b5aa89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      accounts/abi/bind/base.go

@ -256,13 +256,10 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i
return nil, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet")
}
if opts.GasPrice == nil {
price, err := c.transactor.SuggestGasTipCap(ensureContext(opts.Context))
price, err := c.transactor.SuggestGasPrice(ensureContext(opts.Context))
if err != nil {
return nil, err
}
if head.BaseFee != nil {
price.Add(price, head.BaseFee)
}
opts.GasPrice = price
}
}

Loading…
Cancel
Save