accounts/abi.bind: don't fetch head in transact unless required (#25988)

If GasFeeCap and GasTipCap are specified, we don't need to retrieve the head block for constructing a transaction
This commit is contained in:
Daniel Liu 2025-01-14 10:56:14 +08:00
parent 19085392a2
commit cd9c09f384

View file

@ -377,6 +377,8 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i
)
if opts.GasPrice != nil {
rawTx, err = c.createLegacyTx(opts, contract, input)
} else if opts.GasFeeCap != nil && opts.GasTipCap != nil {
rawTx, err = c.createDynamicTx(opts, contract, input, nil)
} else {
// Only query for basefee if gasPrice not specified
if head, errHead := c.transactor.HeaderByNumber(ensureContext(opts.Context), nil); errHead != nil {