accounts/abi/bind: add accessList support to base bond contract (#30195)

Adding the correct accessList parameter when calling a contract can
reduce gas consumption. However, the current version only allows adding
the accessList manually when constructing the transaction. This PR can
provide convenience for saving gas.
pull/30261/head
ysh0566 4 months ago committed by GitHub
parent b635089c7c
commit 67b8137100
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      accounts/abi/bind/base.go

@ -64,6 +64,7 @@ type TransactOpts struct {
GasFeeCap *big.Int // Gas fee cap to use for the 1559 transaction execution (nil = gas price oracle) GasFeeCap *big.Int // Gas fee cap to use for the 1559 transaction execution (nil = gas price oracle)
GasTipCap *big.Int // Gas priority fee cap to use for the 1559 transaction execution (nil = gas price oracle) GasTipCap *big.Int // Gas priority fee cap to use for the 1559 transaction execution (nil = gas price oracle)
GasLimit uint64 // Gas limit to set for the transaction execution (0 = estimate) GasLimit uint64 // Gas limit to set for the transaction execution (0 = estimate)
AccessList types.AccessList // Access list to set for the transaction execution (nil = no access list)
Context context.Context // Network context to support cancellation and timeouts (nil = no timeout) Context context.Context // Network context to support cancellation and timeouts (nil = no timeout)
@ -307,13 +308,14 @@ func (c *BoundContract) createDynamicTx(opts *TransactOpts, contract *common.Add
Gas: gasLimit, Gas: gasLimit,
Value: value, Value: value,
Data: input, Data: input,
AccessList: opts.AccessList,
} }
return types.NewTx(baseTx), nil return types.NewTx(baseTx), nil
} }
func (c *BoundContract) createLegacyTx(opts *TransactOpts, contract *common.Address, input []byte) (*types.Transaction, error) { func (c *BoundContract) createLegacyTx(opts *TransactOpts, contract *common.Address, input []byte) (*types.Transaction, error) {
if opts.GasFeeCap != nil || opts.GasTipCap != nil { if opts.GasFeeCap != nil || opts.GasTipCap != nil || opts.AccessList != nil {
return nil, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet") return nil, errors.New("maxFeePerGas or maxPriorityFeePerGas or accessList specified but london is not active yet")
} }
// Normalize value // Normalize value
value := opts.Value value := opts.Value

Loading…
Cancel
Save