Skip to content

Commit 38a728d

Browse files
author
NullpointerW
committed
fix
1 parent af004b2 commit 38a728d

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

cmd.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import (
77
"strconv"
88
)
99

10-
//var (
11-
// WallNum int
12-
// Val string
13-
//)
10+
var (
11+
Endpoint string
12+
)
1413

1514
var ethwt = &cobra.Command{
1615
Use: "ethwt",
@@ -60,8 +59,7 @@ var pa = &cobra.Command{
6059
}
6160

6261
func init() {
63-
//tx.Flags().StringVarP(&Val, "val", "v", "0", "Value amount of ETH for each transfer")
64-
//gen.Flags().IntVarP(&WallNum, "walletNum", "n", 1, "The number of wallets generated")
62+
tx.Flags().StringVarP(&Endpoint, "endpoint", "edp", "https://ethereum.publicnode.com", "Network rpc endpoint")
6563
ethwt.AddCommand(tx, gen, pa)
6664
}
6765

pkg/tx/transfer.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,12 @@ func Transfer(pk string, to string, val string, data []byte, ec *ethclient.Clien
7272
return "", err
7373
}
7474
fmt.Println("maxPriorityFeePerGas:", gasTipCap, "GasFeeCap:", maxFeePerGas, "Gas:", estimatedGas)
75+
cid, err := ec.ChainID(context.Background())
76+
if err != nil {
77+
return "", fmt.Errorf("get chainID error:%w", err)
78+
}
7579
tx := &types.DynamicFeeTx{
76-
ChainID: big.NewInt(1),
80+
ChainID: cid,
7781
Nonce: nonce,
7882
GasTipCap: gasTipCap, // maxPriorityFeePerGas
7983
GasFeeCap: maxFeePerGas, // max Fee

transfer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type TxRecord struct {
1919
}
2020

2121
func Transfer(val string) {
22-
ec, err := ethclient.Dial("https://ethereum.publicnode.com")
22+
ec, err := ethclient.Dial(Endpoint)
2323
if err != nil {
2424
fmt.Printf("Failed to connect to the Ethereum client: %v", err)
2525
}

transfer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ package main
33
import "testing"
44

55
func TestTransfer(t *testing.T) {
6-
Transfer("0.0001")
6+
Transfer("0.002")
77
}

0 commit comments

Comments
 (0)