@@ -54,23 +54,25 @@ func (c *ExecutionLayer) NewTransactOpts(k *ecdsa.PrivateKey) (*bind.TransactOpt
5454 if err != nil {
5555 return nil , err
5656 }
57- block , err := c .client .BlockByNumber (ctx , nil )
57+ fh , err := c .client .FeeHistory (ctx , 3 , nil , [] float64 { 50 } )
5858 if err != nil {
5959 return nil , err
6060 }
61- baseFee := block .BaseFee ()
62- tip , err := c .client .SuggestGasTipCap (ctx )
63- if err != nil {
64- return nil , err
61+ rewards := new (big.Int )
62+ for _ , r := range fh .Reward {
63+ rewards .Add (rewards , r [0 ])
6564 }
66- max := big .NewInt (0 ).Add (tip , baseFee )
67- max .Sub (max , big .NewInt (1 ))
68- txo .GasFeeCap = max
69- txo .GasTipCap = tip
65+ txo .GasTipCap = rewards .Div (rewards , big .NewInt (int64 (len (fh .Reward ))))
7066
7167 return txo , nil
7268}
7369
70+ func (c * ExecutionLayer ) FeeHistory (blockCount uint64 , lastBlock * big.Int , rewardPercentiles []float64 ) (* ethereum.FeeHistory , error ) {
71+ ctx , cancel := context .WithTimeout (context .Background (), DefaultTimeout )
72+ defer cancel ()
73+ return c .client .FeeHistory (ctx , blockCount , lastBlock , rewardPercentiles )
74+ }
75+
7476func (c * ExecutionLayer ) GetChainID () (* big.Int , error ) {
7577 ctx , cancel := context .WithTimeout (context .Background (), DefaultTimeout )
7678 defer cancel ()
0 commit comments