├── .env ├── addresses.csv ├── go.mod ├── go.sum ├── main.go └── readme.md /.env: -------------------------------------------------------------------------------- 1 | API_KEY= 2 | SECRET_KEY= 3 | COIN=BNB 4 | NETWORK=OPBNB 5 | BASEURL=https://api2.binance.com -------------------------------------------------------------------------------- /addresses.csv: -------------------------------------------------------------------------------- 1 | 0x000,0.005 2 | 0x111,0.005 -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module withdraw 2 | 3 | go 1.21.5 4 | 5 | require ( 6 | github.com/binance/binance-connector-go v0.5.2 7 | github.com/joho/godotenv v1.5.1 8 | ) 9 | 10 | require ( 11 | github.com/bitly/go-simplejson v0.5.0 // indirect 12 | github.com/gorilla/websocket v1.5.0 // indirect 13 | ) 14 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/binance/binance-connector-go v0.5.2 h1:FZvVn6Tsy1XQzMagwnoDF6yvlawQE4wimAZEmpi6PAA= 2 | github.com/binance/binance-connector-go v0.5.2/go.mod h1:p9rdJx+s01YdOhyjJRM+HxoouocCnuLeM2yhSftHkWQ= 3 | github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y= 4 | github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= 5 | github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= 6 | github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= 7 | github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= 8 | github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= 9 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/csv" 6 | "fmt" 7 | "io" 8 | "os" 9 | "strconv" 10 | "time" 11 | 12 | binance_connector "github.com/binance/binance-connector-go" 13 | "github.com/joho/godotenv" 14 | ) 15 | 16 | var ( 17 | apiKey string 18 | secretKey string 19 | coin string 20 | network string 21 | baseURL string 22 | ) 23 | 24 | func init() { 25 | err := godotenv.Load() 26 | if err != nil { 27 | fmt.Println("Error loading .env file") 28 | return 29 | } 30 | 31 | apiKey = os.Getenv("API_KEY") 32 | secretKey = os.Getenv("SECRET_KEY") 33 | coin = os.Getenv("COIN") 34 | network = os.Getenv("NETWORK") 35 | baseURL = os.Getenv("BASEURL") 36 | 37 | // 启动自检 38 | if apiKey == "" || secretKey == "" || coin == "" || network == "" || baseURL == "" { 39 | panic("请在.env文件中填写API_KEY、SECRET_KEY、COIN、NETWORK、BASEURL") 40 | } 41 | 42 | } 43 | 44 | func withdraw(client *binance_connector.Client, asset, address string, amount float64, network string) error { 45 | // Define the withdraw request parameters 46 | withdrawRequest := client.NewWithdrawService(). 47 | Coin(asset). 48 | Address(address). 49 | Amount(amount). 50 | Network(network) 51 | 52 | // Send the withdraw request 53 | result, err := withdrawRequest.Do(context.Background()) 54 | if err != nil { 55 | return err 56 | } 57 | 58 | fmt.Printf("Withdraw result: %v\n", result) 59 | return nil 60 | } 61 | 62 | func main() { 63 | // Initialise the client 64 | client := binance_connector.NewClient(apiKey, secretKey, baseURL) 65 | 66 | // Read address and amount data from a CSV file and load them into a slice for looping 67 | file, err := os.Open("addresses.csv") 68 | if err != nil { 69 | fmt.Println("Error opening CSV file", err) 70 | return 71 | } 72 | defer file.Close() 73 | reader := csv.NewReader(file) 74 | var addressAmountPairs []struct { 75 | Address string 76 | Amount float64 77 | } 78 | 79 | for { 80 | record, err := reader.Read() 81 | if err == io.EOF { 82 | break 83 | } 84 | if err != nil { 85 | fmt.Println("Error reading CSV record", err) 86 | return 87 | } 88 | 89 | amount, err := strconv.ParseFloat(record[1], 64) 90 | if err != nil { 91 | fmt.Println("Error parsing amount from CSV", err) 92 | continue 93 | } 94 | 95 | addressAmountPair := struct { 96 | Address string 97 | Amount float64 98 | }{ 99 | Address: record[0], 100 | Amount: amount, 101 | } 102 | 103 | addressAmountPairs = append(addressAmountPairs, addressAmountPair) 104 | } 105 | ctx := context.Background() 106 | accountInfo, err := client.NewGetAccountService().Do(ctx) 107 | if err != nil { 108 | fmt.Println(err) 109 | return 110 | } 111 | fmt.Println(accountInfo.Balances) 112 | 113 | // Now you can loop over the addressAmountPairs slice for further processing 114 | for _, pair := range addressAmountPairs { 115 | fmt.Printf("Address: %s, Amount: %.2f\n", pair.Address, pair.Amount) 116 | err := withdraw(client, coin, pair.Address, pair.Amount, network) 117 | if err != nil { 118 | fmt.Println("Error withdrawing ", coin, err) 119 | return 120 | } 121 | time.Sleep(2 * time.Second) 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## 用途 2 | 用于批量向不同地址提币,通过**同一网络**提取**同一币种**,但可以对每个地址提取**不同数量** 3 | 4 | ## 使用方法 5 | 1. 去币安开通API,需要绑定IP,开通提币权限 6 | 2. 将向安API的API_KEY和SECRET_KEY填写到.env文件中 7 | 3. 在.env文件中配置需要提取的币种以及使用的网络,默认案例为BNB币种和OPBNB网络 8 | 4. 在addresses.csv文件中配置提币目标地址和每个地址的数量,格式在csv文件中 9 | 5. 运行可执行文件(可以直接go run main.go)或者下载编译好的执行文件 10 | 11 | ## 注意事项(主要是网络问题) 12 | 1. 国内IP无法裸连币安API,可能需要海外服务器 13 | 2. 无法使用梯子的原因:币安API提币需要绑定IP,使用梯子后会改变IP 14 | 3. 配置服务器后,币安API需要绑定服务器IP 15 | 4. 服务器不能选用美国IP,因为美国是币安的限制地区 --------------------------------------------------------------------------------