Created
January 12, 2019 07:22
-
-
Save zapkub/21adaf61e4b7b7985b6a3c643a35499e 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() | |
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