Created
January 11, 2019 14:27
-
-
Save zapkub/3759ad287332015ef9f3ad15f23f4ffc 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.AutoSequence{ | |
horizon.DefaultTestNetClient, | |
}, | |
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) | |
resp, err := horizon.DefaultTestNetClient.SubmitTransaction(txeB64) | |
fmt.Println(resp.Hash) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment