Created
January 11, 2019 13:56
-
-
Save zapkub/53579bfa8c091374e52b7aee6f428469 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" | |
) | |
// Genesis cmd | |
// This excutable will create | |
// - new Master keypair as distributor | |
// - create new Issuer keypair and send Asset to distributor | |
func panicErr(err error) { | |
if err != nil { | |
panic(err) | |
} | |
} | |
func main() { | |
fmt.Println("Hello world") | |
issuerKeypair, err := keypair.Random() | |
if err != nil { | |
panic(err) | |
} | |
fmt.Printf("%s %s", issuerKeypair.Address(), issuerKeypair.Seed()) | |
{ | |
// Request to Friendbot to Open account | |
// TestNet Only | |
url := fmt.Sprintf("https://friendbot.stellar.org?addr=%s", issuerKeypair.Address()) | |
resp, err := http.Get(url) | |
panicErr(err) | |
if resp.StatusCode == http.StatusOK { | |
fmt.Println("Account has been completed open") | |
} | |
} | |
distributorKeypair, err := keypair.Random() | |
tx, err := build.Transaction( | |
build.SourceAccount{AddressOrSeed: issuerKeypair.Address()}, | |
build.TestNetwork, | |
build.CreateAccount( | |
build.Destination{ | |
AddressOrSeed: distributorKeypair.Address(), | |
}, | |
// This mean XLM | |
build.NativeAmount{ | |
Amount: "500", | |
}, | |
), | |
build.MemoText{ | |
Value: "Distributor account", | |
}, | |
) | |
txe, err := tx.Sign(issuerKeypair.Seed()) | |
txeB64, err := txe.Base64() | |
panicErr(err) | |
fmt.Println(txeB64) | |
horizon.DefaultTestNetClient.SubmitTransaction(txeB64) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment