# SUI交互测试网自动领水脚本

By [BSD](https://paragraph.com/@bsd) · 2022-11-16

---

SUI交互测试网自动领水脚本

开发语言：go

Discord交流: [Link](https://discord.gg/q8QK4w3RtE)

Twitter：[@ananpt0](https://twitter.com/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.")
        }
    }
    

![](https://storage.googleapis.com/papyrus_images/b74cb41a1bc4c40540301484068219051ff65f505134986965b8f5bfe05bd472.png)

---

*Originally published on [BSD](https://paragraph.com/@bsd/sui-2)*
