@@ -54,6 +54,25 @@ func main() {
54
54
55
55
fmt .Println ("latest block number: " , latestBlock .Number (), "nonce: " , nonce )
56
56
57
+ // bundle price
58
+ /*
59
+ Unlike sorting in the tx pool based on tx gas prices, the acceptance of a bundle is determined by its overall gas price,
60
+ not the gas price of a single transaction. If the overall bundle price is too low, it will be rejected by the network.
61
+ The rules for calculating the bundle price are as follows:
62
+ bundlePrice = sum(gasFee of each transaction) / sum(gas used of each transaction)
63
+ Developers should ensure that the bundlePrice always exceeds the value returned by the eth_bundlePrice API endpoint.
64
+ */
65
+ bundlePrice , err := bundleCli .BundlePrice (context .Background ())
66
+ if err != nil {
67
+ panic (err )
68
+ }
69
+ fmt .Println ("bundle price: " , bundlePrice )
70
+
71
+ if bundlePrice == nil {
72
+ // set default
73
+ bundlePrice = big .NewInt (5e9 )
74
+ }
75
+
57
76
bundle := types.SendBundleArgs {
58
77
Txs : make ([]hexutil.Bytes , 0 ),
59
78
MaxBlockNumber : 0 ,
@@ -67,7 +86,7 @@ func main() {
67
86
To : & address ,
68
87
Value : big .NewInt (params .GWei ),
69
88
Gas : uint64 (5000000 ),
70
- GasPrice : big . NewInt ( 5e9 ) ,
89
+ GasPrice : bundlePrice ,
71
90
Data : nil ,
72
91
}
73
92
@@ -100,13 +119,6 @@ func main() {
100
119
bundleJson , _ := jsoniter .Marshal (bundleQuery )
101
120
fmt .Println ("bundle queried: " , string (bundleJson ))
102
121
103
- // bundle price
104
- bundlePrice , err := bundleCli .BundlePrice (context .Background ())
105
- if err != nil {
106
- panic (err )
107
- }
108
- fmt .Println ("bundle price: " , bundlePrice )
109
-
110
122
// builders
111
123
builders , err := bundleCli .Builders (context .Background ())
112
124
if err != nil {
0 commit comments