@@ -14,7 +14,7 @@ import (
14
14
"math/big"
15
15
)
16
16
17
- func Transfer (pk string , to string , val string , data []byte , ec * ethclient.Client ) (txHash string , err error ) {
17
+ func Transfer (pk string , to string , val string , data []byte , ec * ethclient.Client ) (txHash common. Hash , err error ) {
18
18
privateKeyHex := pk
19
19
privateKey , err := crypto .HexToECDSA (privateKeyHex )
20
20
if err != nil {
@@ -39,7 +39,7 @@ func Transfer(pk string, to string, val string, data []byte, ec *ethclient.Clien
39
39
wei , ok := util .ToWei (val )
40
40
if ! ok {
41
41
fmt .Println ("invalid eth value:" , val )
42
- return "" , err
42
+ return common. Hash {} , err
43
43
}
44
44
45
45
gasTipCap , err := ec .SuggestGasTipCap (context .Background ())
@@ -69,12 +69,12 @@ func Transfer(pk string, to string, val string, data []byte, ec *ethclient.Clien
69
69
70
70
estimatedGas , err := ec .EstimateGas (context .Background (), msg )
71
71
if err != nil {
72
- return "" , err
72
+ return common. Hash {} , err
73
73
}
74
74
fmt .Println ("maxPriorityFeePerGas:" , gasTipCap , "GasFeeCap:" , maxFeePerGas , "Gas:" , estimatedGas )
75
75
cid , err := ec .ChainID (context .Background ())
76
76
if err != nil {
77
- return "" , fmt .Errorf ("get chainID error:%w" , err )
77
+ return common. Hash {} , fmt .Errorf ("get chainID error:%w" , err )
78
78
}
79
79
tx := & types.DynamicFeeTx {
80
80
ChainID : cid ,
@@ -92,8 +92,8 @@ func Transfer(pk string, to string, val string, data []byte, ec *ethclient.Clien
92
92
// 创建交易
93
93
signedTx , err := types .SignTx (txn , types .NewCancunSigner (tx .ChainID ), privateKey )
94
94
if err != nil {
95
- return "" , err
95
+ return common. Hash {} , err
96
96
}
97
97
err = ec .SendTransaction (context .Background (), signedTx )
98
- return txn .Hash (). String () , err
98
+ return txn .Hash (), err
99
99
}
0 commit comments