Skip to content

Commit 67b8137

Browse files
authored
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.
1 parent b635089 commit 67b8137

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

accounts/abi/bind/base.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ type TransactOpts struct {
5959
Nonce *big.Int // Nonce to use for the transaction execution (nil = use pending state)
6060
Signer SignerFn // Method to use for signing the transaction (mandatory)
6161

62-
Value *big.Int // Funds to transfer along the transaction (nil = 0 = no funds)
63-
GasPrice *big.Int // Gas price to use for the transaction execution (nil = gas price oracle)
64-
GasFeeCap *big.Int // Gas fee cap to use for the 1559 transaction execution (nil = gas price oracle)
65-
GasTipCap *big.Int // Gas priority fee cap to use for the 1559 transaction execution (nil = gas price oracle)
66-
GasLimit uint64 // Gas limit to set for the transaction execution (0 = estimate)
62+
Value *big.Int // Funds to transfer along the transaction (nil = 0 = no funds)
63+
GasPrice *big.Int // Gas price to use for the transaction execution (nil = gas price oracle)
64+
GasFeeCap *big.Int // Gas fee cap to use for the 1559 transaction execution (nil = gas price oracle)
65+
GasTipCap *big.Int // Gas priority fee cap to use for the 1559 transaction execution (nil = gas price oracle)
66+
GasLimit uint64 // Gas limit to set for the transaction execution (0 = estimate)
67+
AccessList types.AccessList // Access list to set for the transaction execution (nil = no access list)
6768

6869
Context context.Context // Network context to support cancellation and timeouts (nil = no timeout)
6970

@@ -300,20 +301,21 @@ func (c *BoundContract) createDynamicTx(opts *TransactOpts, contract *common.Add
300301
return nil, err
301302
}
302303
baseTx := &types.DynamicFeeTx{
303-
To: contract,
304-
Nonce: nonce,
305-
GasFeeCap: gasFeeCap,
306-
GasTipCap: gasTipCap,
307-
Gas: gasLimit,
308-
Value: value,
309-
Data: input,
304+
To: contract,
305+
Nonce: nonce,
306+
GasFeeCap: gasFeeCap,
307+
GasTipCap: gasTipCap,
308+
Gas: gasLimit,
309+
Value: value,
310+
Data: input,
311+
AccessList: opts.AccessList,
310312
}
311313
return types.NewTx(baseTx), nil
312314
}
313315

314316
func (c *BoundContract) createLegacyTx(opts *TransactOpts, contract *common.Address, input []byte) (*types.Transaction, error) {
315-
if opts.GasFeeCap != nil || opts.GasTipCap != nil {
316-
return nil, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet")
317+
if opts.GasFeeCap != nil || opts.GasTipCap != nil || opts.AccessList != nil {
318+
return nil, errors.New("maxFeePerGas or maxPriorityFeePerGas or accessList specified but london is not active yet")
317319
}
318320
// Normalize value
319321
value := opts.Value

0 commit comments

Comments
 (0)