forked from blackmoshui/solana_summer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
93 lines (77 loc) · 2.02 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package main
import (
"context"
"encoding/base64"
"fmt"
bin "github.com/gagliardetto/binary"
"github.com/gagliardetto/solana-go"
"github.com/gagliardetto/solana-go/rpc"
"github.com/go-resty/resty/v2"
"github.com/tidwall/gjson"
"log/slog"
"time"
)
var (
client = resty.New().SetTimeout(30 * time.Second)
headers = map[string]string{
"Origin": "https://jup.ag",
}
rpcClient = rpc.NewWithHeaders("https://jupiter-fe.helius-rpc.com/", headers)
)
func main() {
wallet, _ := solana.WalletFromPrivateKeyBase58("这里填入你的私钥")
fmt.Println(wallet.PublicKey().String())
go fuck(wallet)
go fuck(wallet)
go fuck(wallet)
go fuck(wallet)
select {}
}
func fuck(wallet *solana.Wallet) {
for {
txRaw := GetTx(wallet.PublicKey().String())
if txRaw == "" {
continue
}
SendTx(wallet, txRaw)
}
}
func GetTx(address string) string {
payload := map[string]interface{}{
"account": address,
}
resp, err := client.R().SetBody(payload).Post("https://proxy.dial.to/?url=https%3A%2F%2Fsolanasummer.click%2Fon%2Fmint")
if err != nil {
slog.Error("request blink error: ", slog.String("error", err.Error()))
return ""
}
return gjson.Get(resp.String(), "transaction").String()
}
func SendTx(wallet *solana.Wallet, rawtx string) {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
txData, err := base64.StdEncoding.DecodeString(rawtx)
if err != nil {
slog.Error("decode tx error: ", slog.String("error", err.Error()))
return
}
tx, err := solana.TransactionFromDecoder(bin.NewBinDecoder(txData))
if err != nil {
slog.Error("decode tx error: ", slog.String("error", err.Error()))
return
}
_, err = tx.PartialSign(func(key solana.PublicKey) *solana.PrivateKey {
if wallet.PublicKey().Equals(key) {
return &wallet.PrivateKey
}
return nil
})
if err != nil {
slog.Error("sign tx error: ", slog.String("error", err.Error()))
return
}
_, err = rpcClient.SendTransaction(ctx, tx)
if err != nil {
slog.Error("send tx error: ", slog.String("error", err.Error()))
}
}