Skip to content

Instantly share code, notes, and snippets.

View ire-and-curses's full-sized avatar

Eric Saunders ire-and-curses

View GitHub Profile
@ire-and-curses
ire-and-curses / txnbuild-deleteOffer.go
Last active May 1, 2019 21:24
Using the txnbuild package to configure a new ManageOffer operation for deletion
// Create a ManageOffer operation configured for deletion
op, err := DeleteOfferOp(offerID)
@ire-and-curses
ire-and-curses / txnbuild-setOptionsFlags.go
Last active May 1, 2019 21:23
Using the txnbuild package to set account flags in a SetOptions operation
// Set only the fields we're interested in
op := SetOptions{
ClearFlags: []AccountFlag{AuthRevocable},
SetFlags: []AccountFlag{AuthRequired, AuthImmutable},
}
@ire-and-curses
ire-and-curses / txnbuild-buildSignSubmit.go
Created May 1, 2019 21:12
Using the txnbuild package to set XDR fields, sign and submit a transaction
// Serialise the transaction to XDR, and sign it
err := tx.Build()
err = tx.Sign(kp)
// Submit the transaction
resp, err := client.SubmitTransaction(tx)
@ire-and-curses
ire-and-curses / txnbuild-createAccount.go
Created May 1, 2019 21:07
Using the txnbuild package to build a transaction that would create a Stellar account
// An operation to create a new Stellar account funded from an existing one
createAccountOp := txnbuild.CreateAccount{
Destination: "GDKT2RF3P7VVKOCAN5UXZ2WNGRXTRWNWOCWZZWRL2WQPPROCFSE3RGRQ",
Amount: "10",
}
// Construct the transaction that will carry the operation
tx := txnbuild.Transaction{
SourceAccount: horizonAcct,
Operations: []txnbuild.Operation{&createAccountOp},
@ire-and-curses
ire-and-curses / horizonclient-accountDetail.go
Last active May 1, 2019 21:05
Using the horizonclient package to query a Stellar Horizon server for account information
// Create a new randomly generated address
kp, err := keypair.Random()
// Create and fund the new address on TestNet, using friendbot
client := horizonclient.DefaultTestNetClient
resp, err := client.Fund(kp.Address())
// Get information about the account we just created
accountRequest := horizonclient.AccountRequest{AccountID: kp.Address()}
horizonAcct, err := client.AccountDetail(accountRequest)
@ire-and-curses
ire-and-curses / keybase.md
Created August 21, 2018 18:36
Keybase proof

Keybase proof

I hereby claim:

  • I am ire-and-curses on github.
  • I am ericsaunders (https://keybase.io/ericsaunders) on keybase.
  • I have a public key ASDy82e_GBAr5Qx-J6xqYVRrq9NRhHb1y68pXwz7kgJgJwo

To claim this, I am signing this object: