# SUI批量创建钱包地址脚本

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

---

批量生成SUI钱包地址本地保存

脚本语言：go

版本：go1.19

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

Twitter：[@ananpt0](https://twitter.com/ananpt0)

    package main
    
    import (
        "encoding/json"
        "fmt"
        "github.com/coming-chat/go-sui/account"
        "github.com/tyler-smith/go-bip39"
        "io/ioutil"
    )
    
    type SuiWallet struct {
        Address  string `json:"address"`
        Mnemonic string `json:"mnemonic"`
        Private  string `json:"private"`
        Public   string `json:"public"`
    }
    
    func Create(num int) {
        fmt.Printf("[+]Create Wallet :%d \n", num)
        wallets := make([]SuiWallet, 0)
        for i := 0; i < num; i++ {
            fmt.Printf("[+]Wallet : %d \n", i+1)
            entropy, _ := bip39.NewEntropy(256)
            mnemonic, _ := bip39.NewMnemonic(entropy)
            fmt.Println("[+]Mnemonic : ", mnemonic)
            acc, _ := account.NewAccountWithMnemonic(mnemonic)
            fmt.Printf("[+]privateKey = %x\n", acc.PrivateKey[:32])
            fmt.Printf("[+] publicKey = %x\n", acc.PublicKey)
            fmt.Printf("[+]   address = %v\n", acc.Address)
            wallet := SuiWallet{}
            wallet.Mnemonic = mnemonic
            wallet.Address = acc.Address
            wallet.Private = fmt.Sprintf("%x", acc.PrivateKey[:32])
            wallet.Public = fmt.Sprintf("%x", acc.PublicKey)
            wallets = append(wallets, wallet)
        }
            //保存到本地json文件
        walletsJson, _ := json.Marshal(wallets)
        ioutil.WriteFile("wallet.json", walletsJson, 0666)
    }
    
    func main() {
       //创建100个钱包地址
       Create(100)
    }
    

![开始创建](https://storage.googleapis.com/papyrus_images/8a34cadd24d3d1286bedcb1ba257724443e42697fd802ffd38c1bff94971c749.png)

开始创建

---

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