Skip to content

Instantly share code, notes, and snippets.

@zapkub
Created January 12, 2019 07:22
Show Gist options
  • Save zapkub/21adaf61e4b7b7985b6a3c643a35499e to your computer and use it in GitHub Desktop.
Save zapkub/21adaf61e4b7b7985b6a3c643a35499e to your computer and use it in GitHub Desktop.
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()
tx, err := build.Transaction(
build.SourceAccount{
AddressOrSeed: masterAccountKeypair.Address(),
},
build.TestNetwork,
build.AutoSequence{
SequenceProvider: horizon.DefaultTestNetClient,
},
// Operation
build.CreateAccount(
build.Destination{
AddressOrSeed: lisaWalletKeypair.Address(),
},
build.NativeAmount{
Amount: "50",
},
),
)
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("Tx hash: %s\n", resp.Hash)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment