SUI交互测试网自动领水脚本
开发语言:go
Discord交流: Link
Twitter:@ananpt0
package main
import (
"errors"
"fmt"
"github.com/go-resty/resty/v2"
"strings"
)
type GasReq struct {
FixedAmountRequest FixedAmount `json:"FixedAmountRequest"`
}
type FixedAmount struct {
Recipient string `json:"recipient"`
}
var FaucetURL = "https://faucet.devnet.sui.io/gas"
func Faucet(address string, proxy string) error {
fmt.Println("[+]Request DevNet SUI Tokens")
req := FixedAmount{
Recipient: address,
}
gas := GasReq{FixedAmountRequest: req}
httpClient := resty.New()
if len(proxy) > 0 {
httpClient.SetProxy(proxy)
}
resp, err := httpClient.R().
SetBody(gas).
Post(FaucetURL)
if err != nil {
fmt.Println(err)
return err
}
b := resp.Body()
if strings.Contains(string(b), "error code: 1015") {
return errors.New("fail")
}
return nil
}
func main() {
//钱包地址:0x
walletAddress := ""
//http代理服务器地址 示例:http://127.0.0.1:8001
proxy := ""
if err := Faucet(walletAddress, proxy); err == nil {
fmt.Printf("[+] 5 test Sui objects are heading to your wallet,check https://explorer.devnet.sui.io/addresses/%s\n", walletAddress)
} else {
//失败后可以更换Http代理
fmt.Println("Request limit reached, please try again later or change proxy.")
}
}


