Created
January 12, 2019 07:41
-
-
Save zapkub/4515e57fb6bfd4c080a3f9ab4032ee15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/stellar/go/build" | |
"github.com/stellar/go/clients/horizon" | |
"github.com/stellar/go/keypair" | |
"net/http" | |
) | |
func main() { | |
fmt.Println("Hello world") | |
masterAccountKeypair, _ := keypair.Random() | |
{ | |
url := fmt.Sprintf("https://friendbot.stellar.org?addr=%s", masterAccountKeypair.Address()) | |
resp, err := http.Get(url) | |
if err != nil { | |
panic(err) | |
} | |
if resp.StatusCode == http.StatusOK { | |
fmt.Printf("Account has been created ! %s ", masterAccountKeypair.Address()) | |
} | |
} | |
//lisaWalletKeypair, _ := keypair.Random() | |
//jennieWalletKeypair, _ := keypair.Random() | |
//jisooWalletKeypair, _ := keypair.Random() | |
//roseWalletKeypair, _ := keypair.Random() | |
candidateNames := []string{ | |
"lisa", "jennie", "jisoo", "rose", | |
} | |
operations := []build.TransactionMutator{ | |
build.SourceAccount{ | |
AddressOrSeed: masterAccountKeypair.Address(), | |
}, | |
build.TestNetwork, | |
build.AutoSequence{ | |
SequenceProvider: horizon.DefaultTestNetClient, | |
}, | |
} | |
for _, name := range candidateNames { | |
fmt.Printf("Generate wallet for %s\n", name) | |
candidateKeypair, _ := keypair.Random() | |
operations = append(operations, build.CreateAccount( | |
build.Destination{ | |
AddressOrSeed: candidateKeypair.Address(), | |
}, | |
build.NativeAmount{ | |
Amount: "50", | |
}, | |
)) | |
} | |
tx, err := build.Transaction(operations...) | |
if err != nil { | |
panic(err) | |
} | |
txe, err := tx.Sign(masterAccountKeypair.Seed()) | |
if err != nil { | |
panic(err) | |
} | |
txe64, err := txe.Base64() | |
fmt.Println(txe64) | |
resp, err := horizon.DefaultTestNetClient.SubmitTransaction(txe64) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Printf("MasterAccount addr: %s\nsecret: %s\n", masterAccountKeypair.Address(), masterAccountKeypair.Seed()) | |
//fmt.Printf("Jisoo: %s\n", jisooWalletKeypair.Address()) | |
//fmt.Printf("Jennie: %s\n", jennieWalletKeypair.Address()) | |
//fmt.Printf("Rose: %s\n", roseWalletKeypair.Address()) | |
//fmt.Printf("Lisa: %s\n", lisaWalletKeypair.Address()) | |
fmt.Printf("Tx hash: %s\n", resp.Hash) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment