Documentation
¶
Overview ¶
Package microstellar is an easy-to-use Go client for the Stellar network.
go get github.com/0xfe/microstellar
Author: Mohit Muthanna Cheppudira <mohit@muthanna.com>
Usage notes ¶
In Stellar lingo, a private key is called a seed, and a public key is called an address. Seed strings start with "S", and address strings start with "G". (Not techincally accurate, but you get the picture.)
Seed: S6H4HQPE6BRZKLK3QNV6LTD5BGS7S6SZPU3PUGMJDJ26V7YRG3FRNPGA Address: GAUYTZ24ATLEBIV63MXMPOPQO2T6NHI6TQYEXRTFYXWYZ3JOCVO6UYUM
In most the methods below, the first parameter is usually "sourceSeed", which should be the seed of the account that signs the transaction.
You can add a *Options struct to the end of many methods, which set extra parameters on the submitted transaction. If you add new signers via Options, then sourceSeed will not be used to sign the transaction -- and it's okay to use a public address instead of a seed for sourceSeed. See examples for how to use Options.
Amounts in Microstellar are typically represented as strings, to protect users from accidentaly performing floating point operations on them. The convenience methods `ParseAmount` and `ToAmountString` to convert the strings to `int64` values that represent a `10e7` multiple of the numeric value. E.g.,
ParseAmount("2.5") == int64(25000000)
ToAmountString(1000000) == "1.000000"
You can use ErrorString(...) to extract the Horizon error from a returned error.
Example ¶
// Create a new MicroStellar client connected to a mock network.
ms := New("fake")
// Generate a new random keypair.
pair, _ := ms.CreateKeyPair()
// In stellar, you can create all kinds of asset types -- dollars, houses, kittens. These
// customized assets are called credit assets.
//
// However, the native asset is always lumens (XLM). Lumens are used to pay for transactions
// on the stellar network, and are used to fund the operations of Stellar.
//
// When you first create a key pair, you need to fund it with atleast 0.5 lumens. This
// is called the "base reserve", and makes the account valid. You can only transact to
// and from accounts that maintain the base reserve.
ms.FundAccount("S6H4HQPE6BRZKLK3QNV6LTD5BGS7S6SZPU3PUGMJDJ26V7YRG3FRNPGA", pair.Address, "1")
// On the test network, you can ask FriendBot to fund your account. You don't need to buy
// lumens. (If you do want to buy lumens for the test network, call me!)
FundWithFriendBot(pair.Address)
// Now load the account from the ledger and check its balance.
account, _ := ms.LoadAccount(pair.Address)
log.Printf("Native Balance: %v XLM", account.GetNativeBalance())
// Note that we used GetNativeBalance() above, which implies lumens as the asset. You
// could also do the following.
log.Printf("Native Balance: %v XLM", account.GetBalance(NativeAsset))
// Pay your buddy 3 lumens.
ms.PayNative("S6H4HQPE6BRZKLK3QNV6LTD5BGS7S6SZPU3PUGMJDJ26V7YRG3FRNPGA",
"GAUYTZ24ATLEBIV63MXMPOPQO2T6NHI6TQYEXRTFYXWYZ3JOCVO6UYUM", "3")
// Alternatively, be explicit about lumens.
ms.Pay("S6H4HQPE6BRZKLK3QNV6LTD5BGS7S6SZPU3PUGMJDJ26V7YRG3FRNPGA",
"GAUYTZ24ATLEBIV63MXMPOPQO2T6NHI6TQYEXRTFYXWYZ3JOCVO6UYUM", "3", NativeAsset)
// Create a credit asset called USD issued by anchor GAT5GKDILNY2G6NOBEIX7XMGSPPZD5MCHZ47MGTW4UL6CX55TKIUNN53
USD := NewAsset("USD", "GAT5GKDILNY2G6NOBEIX7XMGSPPZD5MCHZ47MGTW4UL6CX55TKIUNN53", Credit4Type)
// Pay your buddy 3 USD and add a memo
ms.Pay("S6H4HQPE6BRZKLK3QNV6LTD5BGS7S6SZPU3PUGMJDJ26V7YRG3FRNPGA",
"GAUYTZ24ATLEBIV63MXMPOPQO2T6NHI6TQYEXRTFYXWYZ3JOCVO6UYUM",
"3", USD,
Opts().WithMemoText("for beer"))
// Create a trust line to the USD credit asset with a limit of 1000.
ms.CreateTrustLine("S4H4HQPE6BRZKLK3QNV6LTD5BGS7S6SZPU3PUGMJDJ26V7YRG3FRNPGA", USD, "10000")
// Check your balances.
account, _ = ms.LoadAccount("GAUYTZ24ATLEBIV63MXMPOPQO2T6NHI6TQYEXRTFYXWYZ3JOCVO6UYUM")
log.Printf("USD Balance: %v USD", account.GetBalance(USD))
log.Printf("Native Balance: %v XLM", account.GetNativeBalance())
// Find your home domain.
log.Printf("Home domain: %s", account.HomeDomain)
// Who are the signers on the account?
for i, s := range account.Signers {
log.Printf("Signer %d (weight: %v): %v", i, s.PublicKey, s.Weight)
}
log.Printf("ok")
Example (Multisig) ¶
// Create a new MicroStellar client connected to a mock network.
ms := New("fake")
// Add two signers to the source account with weight 1 each
ms.AddSigner(
"S8H4HQPE6BRZKLK3QNV6LTD5BGS7S6SZPU3PUGMJDJ26V7YRG3FRNPGA", // source account
"G6H4HQPE6BRZKLK3QNV6LTD5BGS7S6SZPU3PUGMJDJ26V7YRG3FRNPGA", // signer address
1) // weight
ms.AddSigner(
"S8H4HQPE6BRZKLK3QNV6LTD5BGS7S6SZPU3PUGMJDJ26V7YRG3FRNPGA", // source account
"G9H4HQPE6BRZKLK3QNV6LTD5BGS7S6SZPU3PUGMJDJ26V7YRG3FRNPGB", // signer address
1) // weight
// Set the low, medium, and high thresholds of the account. (Here we require a minimum
// total signing weight of 2 for all operations.)
ms.SetThresholds("S8H4HQPE6BRZKLK3QNV6LTD5BGS7S6SZPU3PUGMJDJ26V7YRG3FRNPGA", 2, 2, 2)
// Kill the master weight of account, so only the new signers can sign transactions
ms.SetMasterWeight("S8H4HQPE6BRZKLK3QNV6LTD5BGS7S6SZPU3PUGMJDJ26V7YRG3FRNPGA", 0,
Opts().WithSigner("S2H4HQPE6BRZKLK3QNV6LTD5BGS7S6SZPU3PUGMJDJ26V7YRG3FRNPGA"))
// Make a payment (and sign with new signers). Note that the first parameter (source) here
// can be an address instead of a seed (since the seed can't sign anymore.)
ms.PayNative(
"G6H4HQPE6BRZKLK3QNV6LTD5BGS7S6SZPU3PUGMJDJ26V7YRG3FRNPGA", // from
"GAUYTZ24ATLEBIV63MXMPOPQO2T6NHI6TQYEXRTFYXWYZ3JOCVO6UYUM", // to
"3", // amount
Opts().
WithSigner("S1H4HQPE6BRZKLK3QNV6LTD5BGS7S6SZPU3PUGMJDJ26V7YRG3FRNPGA").
WithSigner("S2H4HQPE6BRZKLK3QNV6LTD5BGS7S6SZPU3PUGMJDJ26V7YRG3FRNPGA"))
log.Printf("ok")
Index ¶
- Constants
- Variables
- func ErrorString(err error, showStackTrace ...bool) string
- func FundWithFriendBot(address string) (string, error)
- func ParseAmount(v string) (int64, error)
- func ToAmountString(v int64) string
- func ValidAddress(address string) error
- func ValidAddressOrSeed(addressOrSeed string) bool
- func ValidSeed(seed string) error
- type Account
- type AccountFlags
- type Address
- type Asset
- type AssetType
- type Balance
- type Error
- type HorizonPath
- type KeyPair
- type Link
- type MemoType
- type MicroStellar
- func (ms *MicroStellar) AddSigner(sourceSeed string, signerAddress string, signerWeight uint32, ...) error
- func (ms *MicroStellar) CreateKeyPair() (*KeyPair, error)
- func (ms *MicroStellar) CreateOffer(sourceSeed string, sellAsset *Asset, buyAsset *Asset, price string, ...) error
- func (ms *MicroStellar) CreateTrustLine(sourceSeed string, asset *Asset, limit string, options ...*Options) error
- func (ms *MicroStellar) DeleteOffer(sourceSeed string, offerID string, sellAsset *Asset, buyAsset *Asset, ...) error
- func (ms *MicroStellar) FindPaths(sourceAddress string, destAddress string, destAsset *Asset, destAmount string, ...) ([]Path, error)
- func (ms *MicroStellar) FundAccount(sourceSeed string, addressOrSeed string, amount string, options ...*Options) error
- func (ms *MicroStellar) LoadAccount(address string) (*Account, error)
- func (ms *MicroStellar) LoadOffers(address string, options ...*Options) ([]Offer, error)
- func (ms *MicroStellar) ManageOffer(sourceSeed string, params *OfferParams, options ...*Options) error
- func (ms *MicroStellar) Pay(sourceAddressOrSeed string, targetAddress string, amount string, asset *Asset, ...) error
- func (ms *MicroStellar) PayNative(sourceSeed string, targetAddress string, amount string, options ...*Options) error
- func (ms *MicroStellar) RemoveSigner(sourceSeed string, signerAddress string, options ...*Options) error
- func (ms *MicroStellar) RemoveTrustLine(sourceSeed string, asset *Asset, options ...*Options) error
- func (ms *MicroStellar) Resolve(address string) (string, error)
- func (ms *MicroStellar) SetFlags(sourceSeed string, flags AccountFlags, options ...*Options) error
- func (ms *MicroStellar) SetHomeDomain(sourceSeed string, domain string, options ...*Options) error
- func (ms *MicroStellar) SetMasterWeight(sourceSeed string, weight uint32, options ...*Options) error
- func (ms *MicroStellar) SetThresholds(sourceSeed string, low, medium, high uint32, options ...*Options) error
- func (ms *MicroStellar) UpdateOffer(sourceSeed string, offerID string, sellAsset *Asset, buyAsset *Asset, ...) error
- func (ms *MicroStellar) WatchPayments(address string, options ...*Options) (*PaymentWatcher, error)
- type Offer
- type OfferParams
- type OfferType
- type Options
- func (o *Options) FindPathFrom(sourceAddress string) *Options
- func (o *Options) MakePassive() *Options
- func (o *Options) Through(asset ...*Asset) *Options
- func (o *Options) WithAsset(asset *Asset, maxAmount string) *Options
- func (o *Options) WithContext(context context.Context) *Options
- func (o *Options) WithCursor(cursor string) *Options
- func (o *Options) WithLimit(limit uint) *Options
- func (o *Options) WithMemoID(id uint64) *Options
- func (o *Options) WithMemoText(text string) *Options
- func (o *Options) WithSigner(signerSeed string) *Options
- func (o *Options) WithSortOrder(order SortOrder) *Options
- type Params
- type Path
- type PathResponse
- type Payment
- type PaymentWatcher
- type Seed
- type Signer
- type SortOrder
- type Tx
- func (tx *Tx) Build(sourceAccount build.TransactionMutator, muts ...build.TransactionMutator) error
- func (tx *Tx) Err() error
- func (tx *Tx) GetClient() *horizon.Client
- func (tx *Tx) IsSigned() bool
- func (tx *Tx) Reset()
- func (tx *Tx) Response() string
- func (tx *Tx) SetOptions(options *Options)
- func (tx *Tx) Sign(keys ...string) error
- func (tx *Tx) Submit() error
- func (tx *Tx) WithOptions(options *Options) *Tx
- type TxOptions
Examples ¶
- Package
- Package (Multisig)
- MicroStellar.AddSigner
- MicroStellar.CreateKeyPair
- MicroStellar.CreateOffer
- MicroStellar.CreateTrustLine
- MicroStellar.DeleteOffer
- MicroStellar.FundAccount
- MicroStellar.LoadAccount (Balance)
- MicroStellar.LoadOffers
- MicroStellar.ManageOffer
- MicroStellar.Pay
- MicroStellar.Pay (Memotext)
- MicroStellar.Pay (Multisig)
- MicroStellar.Pay (Path)
- MicroStellar.PayNative
- MicroStellar.RemoveSigner
- MicroStellar.RemoveTrustLine
- MicroStellar.SetFlags
- MicroStellar.SetHomeDomain
- MicroStellar.SetMasterWeight
- MicroStellar.SetThresholds
- MicroStellar.UpdateOffer
- MicroStellar.WatchPayments
- TxOptions (Memotext)
- TxOptions (Multisig)
Constants ¶
const ( // FlagAuthRequired requires the issuing account to give the receiving // account permission to hold the asset. FlagAuthRequired = AccountFlags(1) // FlagAuthRevocable allows the issuer to revoke the credit held by another // account. FlagAuthRevocable = AccountFlags(2) // FlagAuthImmutable means that the other auth parameters can never be set // and the issuer's account can never be deleted. FlagAuthImmutable = AccountFlags(4) )
const ( OfferCreate = OfferType(0) OfferCreatePassive = OfferType(1) OfferUpdate = OfferType(2) OfferDelete = OfferType(3) )
The available offer types.
const ( SortAscending = SortOrder(0) SortDescending = SortOrder(1) )
For use with WithSortOrder
const ( MemoNone = MemoType(0) // No memo MemoID = MemoType(1) // ID memo MemoText = MemoType(2) // Text memo (max 28 chars) MemoHash = MemoType(3) // Hash memo MemoReturn = MemoType(4) // Return hash memo )
Supported memo types.
Variables ¶
var NativeAsset = &Asset{"XLM", "", NativeType}
NativeAsset is a convenience const representing a native asset.
Functions ¶
func ErrorString ¶
ErrorString parses the horizon error out of err.
func FundWithFriendBot ¶
FundWithFriendBot funds address on the test network with some initial funds.
func ParseAmount ¶ added in v0.2.4
ParseAmount converts a currency amount string to an int64
func ToAmountString ¶ added in v0.2.4
ToAmountString converts an int64 amount to a string
func ValidAddress ¶
ValidAddress returns error if address is an invalid stellar address
func ValidAddressOrSeed ¶
ValidAddressOrSeed returns true if the string is a valid address or seed
Types ¶
type Account ¶
type Account struct {
Balances []Balance
Signers []Signer
NativeBalance Balance
HomeDomain string
Sequence string
}
Account represents an account on the stellar network.
func (*Account) GetBalance ¶
GetBalance returns the balance for asset in account. If no balance is found for the asset, returns "".
func (*Account) GetMasterWeight ¶
GetMasterWeight returns the weight of the primary key in the account.
func (*Account) GetNativeBalance ¶
GetNativeBalance returns the balance of the native currency (typically lumens) in the account.
type Asset ¶
type Asset struct {
Code string
Issuer string
Type AssetType // Credit4Type, Credit12Type, NativeType
}
Asset represents a specific asset class on the stellar network. For native assets "Code" and "Issuer" are ignored.
func NewAsset ¶
NewAsset creates a new asset with the given code, issuer, and assetType. assetType can be one of: NativeType, Credit4Type, or Credit12Type.
USD := microstellar.NewAsset("USD", "issuer_address", microstellar.Credit4Type)
func (Asset) ToStellarAsset ¶ added in v0.2.2
ToStellarAsset returns a stellar-go Asset from this one.
type AssetType ¶
type AssetType string
AssetType represents an asset type on the stellar network.
const Credit12Type AssetType = "credit_alphanum12"
Credit12Type represents credit assets with 12-digit codes.
const Credit4Type AssetType = "credit_alphanum4"
Credit4Type represents credit assets with 4-digit codes.
const NativeType AssetType = "native"
NativeType represents native assets (like lumens.)
type HorizonPath ¶ added in v0.2.4
type HorizonPath struct {
DestAmount string `json:"destination_amount"`
DestAssetCode string `json:"destination_asset_code"`
DestAssetIssuer string `json:"destination_asset_issuer"`
DestAssetType string `json:"destination_asset_type"`
SourceAmount string `json:"source_amount"`
SourceAssetCode string `json:"source_asset_code"`
SourceAssetIssuer string `json:"source_asset_issuer"`
SourceAssetType string `json:"source_asset_type"`
Path []struct {
AssetCode string `json:"asset_code"`
AssetIssuer string `json:"asset_issuer"`
AssetType string `json:"asset_type"`
} `json:"path"`
}
HorizonPath is a payment path returned by a horizon server
type KeyPair ¶
KeyPair represents a key pair for a signer on a stellar account. An account can have multiple signers.
type MicroStellar ¶
type MicroStellar struct {
// contains filtered or unexported fields
}
MicroStellar is the user handle to the Stellar network. Use the New function to create a new instance.
func New ¶
func New(networkName string, params ...Params) *MicroStellar
New returns a new MicroStellar client connected that operates on the network specified by networkName. The supported networks are:
public: the public horizon network test: the public horizon testnet fake: a fake network used for tests custom: a custom network specified by the parameters
If you're using "custom", provide the URL and Passphrase to your horizon network server in the parameters.
NewTx("custom", Params{
"url": "https://my-horizon-server.com",
"passphrase": "foobar"})
func (*MicroStellar) AddSigner ¶
func (ms *MicroStellar) AddSigner(sourceSeed string, signerAddress string, signerWeight uint32, options ...*Options) error
AddSigner adds signerAddress as a signer to sourceSeed's account with weight signerWeight.
Example ¶
This example adds a signer to an account.
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Add signer to account
err := ms.AddSigner("SCSMBQYTXKZYY7CLVT6NPPYWVDQYDOQ6BB3QND4OIXC7762JYJYZ3RMK", "GCCRUJJGPYWKQWM5NLAXUCSBCJKO37VVJ74LIZ5AQUKT6KPVCPNAGC4A", 10)
if err != nil {
log.Fatalf("AddSigner: %v", err)
}
fmt.Printf("ok")
Output: ok
func (*MicroStellar) CreateKeyPair ¶
func (ms *MicroStellar) CreateKeyPair() (*KeyPair, error)
CreateKeyPair generates a new random key pair.
Example ¶
This example creates a key pair and displays the private and public keys. In stellar-terminology, the private key is typically called a "seed", and the publick key. an "address."
ms := New("test")
// Generate a new random keypair.
pair, err := ms.CreateKeyPair()
if err != nil {
log.Fatalf("CreateKeyPair: %v", err)
}
// Display address and key
log.Printf("Private seed: %s, Public address: %s", pair.Seed, pair.Address)
fmt.Printf("ok")
Output: ok
func (*MicroStellar) CreateOffer ¶ added in v0.2.1
func (ms *MicroStellar) CreateOffer(sourceSeed string, sellAsset *Asset, buyAsset *Asset, price string, sellAmount string, options ...*Options) error
CreateOffer creates an offer to trade sellAmount of sellAsset held by sourceSeed for buyAsset at price (which buy_unit-over-sell_unit.) The offer is made on Stellar's decentralized exchange (DEX.)
You can use add Opts().MakePassive() to make this a passive offer.
Example ¶
This example creates a passive offer on stellar's DEX.
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Custom USD asset issued by specified issuer
USD := NewAsset("USD", "GAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ", Credit4Type)
// Sell 200 USD on the DEX for lumens (at 2 lumens per USD). This is a passive
// offer. (This is equivalent to an offer to buy 400 lumens for 200 USD.)
err := ms.CreateOffer("SCSMBQYTXKZYY7CLVT6NPPYWVDQYDOQ6BB3QND4OIXC7762JYJYZ3RMK",
USD, NativeAsset, "2", "200",
Opts().MakePassive())
if err != nil {
log.Fatalf("CreateOffer: %v", err)
}
fmt.Printf("ok")
Output: ok
func (*MicroStellar) CreateTrustLine ¶
func (ms *MicroStellar) CreateTrustLine(sourceSeed string, asset *Asset, limit string, options ...*Options) error
CreateTrustLine creates a trustline from sourceSeed to asset, with the specified trust limit. An empty limit string indicates no limit.
Example ¶
This example creates a trust line to a credit asset.
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Custom USD asset issued by specified issuer
USD := NewAsset("USD", "GAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ", Credit4Type)
// Create a trustline to the custom asset with no limit
err := ms.CreateTrustLine("SCSMBQYTXKZYY7CLVT6NPPYWVDQYDOQ6BB3QND4OIXC7762JYJYZ3RMK", USD, "")
if err != nil {
log.Fatalf("CreateTrustLine: %v", err)
}
fmt.Printf("ok")
Output: ok
func (*MicroStellar) DeleteOffer ¶ added in v0.2.1
func (ms *MicroStellar) DeleteOffer(sourceSeed string, offerID string, sellAsset *Asset, buyAsset *Asset, price string, options ...*Options) error
DeleteOffer deletes the specified parameters (assets, price, ID) on the DEX.
Example ¶
This example deletes an existing offer on the DEX.
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Custom USD asset issued by specified issuer
USD := NewAsset("USD", "GAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ", Credit4Type)
// Delete Offer ID 23456 on the DEX.
err := ms.DeleteOffer("SCSMBQYTXKZYY7CLVT6NPPYWVDQYDOQ6BB3QND4OIXC7762JYJYZ3RMK",
"23456", USD, NativeAsset, "0.4")
if err != nil {
log.Fatalf("DeleteOffer: %v", err)
}
fmt.Printf("ok")
Output: ok
func (*MicroStellar) FindPaths ¶ added in v0.2.4
func (ms *MicroStellar) FindPaths(sourceAddress string, destAddress string, destAsset *Asset, destAmount string, options ...*Options) ([]Path, error)
FindPaths finds payment paths between source and dest assets. Use Options.WithAsset to filter the results by source asset and max spend.
func (*MicroStellar) FundAccount ¶
func (ms *MicroStellar) FundAccount(sourceSeed string, addressOrSeed string, amount string, options ...*Options) error
FundAccount creates a new account out of addressOrSeed by funding it with lumens from sourceSeed. The minimum funding amount today is 0.5 XLM.
Example ¶
This example creates a key pair and funds the account with lumens. FundAccount is used for the initial funding of the account -- it is what turns a public address into an account.
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Generate a new random keypair.
pair, err := ms.CreateKeyPair()
if err != nil {
log.Fatalf("CreateKeyPair: %v", err)
}
// Fund the account with 1 lumen from an existing account.
err = ms.FundAccount("SD3M3RG4G54JSFIG4RJYPPKTB4G77IPSXKZPTMN5CKAFWNRQP6V24ZDQ", pair.Address, "1")
if err != nil {
log.Fatalf("FundAccount: %v", ErrorString(err))
}
fmt.Printf("ok")
Output: ok
func (*MicroStellar) LoadAccount ¶
func (ms *MicroStellar) LoadAccount(address string) (*Account, error)
LoadAccount loads the account information for the given address.
Example (Balance) ¶
This example loads and displays the native and a non-native balance on an account.
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Custom USD asset issued by specified issuer
USD := NewAsset("USD", "GAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ", Credit4Type)
// Load account from ledger.
account, err := ms.LoadAccount("GCCRUJJGPYWKQWM5NLAXUCSBCJKO37VVJ74LIZ5AQUKT6KPVCPNAGC4A")
if err != nil {
log.Fatalf("LoadAccount: %v", err)
}
// See balances
log.Printf("Native Balance: %v", account.GetNativeBalance())
log.Printf("USD Balance: %v", account.GetBalance(USD))
fmt.Printf("ok")
Output: ok
func (*MicroStellar) LoadOffers ¶ added in v0.2.1
func (ms *MicroStellar) LoadOffers(address string, options ...*Options) ([]Offer, error)
LoadOffers returns all existing trade offers made by address.
Example ¶
This example lists the offers currently out by an address.
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Get at most 10 offers made by address in descending order
offers, err := ms.LoadOffers("GAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ",
Opts().WithLimit(10).WithSortOrder(SortDescending))
if err != nil {
log.Fatalf("LoadOffers: %v", err)
}
for _, o := range offers {
log.Printf("Offer ID: %v, Selling: %v, Price: %v, Amount: %v", o.ID, o.Selling.Code, o.Price, o.Amount)
}
fmt.Printf("ok")
Output: ok
func (*MicroStellar) ManageOffer ¶ added in v0.2.1
func (ms *MicroStellar) ManageOffer(sourceSeed string, params *OfferParams, options ...*Options) error
ManageOffer lets you trade on the DEX. See the Create/Update/DeleteOffer methods below to see how this is used.
Example ¶
This example creates a new offer using the ManageOffer method.
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Custom USD asset issued by specified issuer
USD := NewAsset("USD", "GAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ", Credit4Type)
// Create an offer to buy 200 lumens at 2 lumens/dollar.
err := ms.ManageOffer("SCSMBQYTXKZYY7CLVT6NPPYWVDQYDOQ6BB3QND4OIXC7762JYJYZ3RMK",
&OfferParams{
OfferType: OfferCreate,
SellAsset: USD,
BuyAsset: NativeAsset,
Price: "2",
SellAmount: "100",
})
if err != nil {
log.Fatalf("ManageOffer: %v", err)
}
fmt.Printf("ok")
Output: ok
func (*MicroStellar) Pay ¶
func (ms *MicroStellar) Pay(sourceAddressOrSeed string, targetAddress string, amount string, asset *Asset, options ...*Options) error
Pay lets you make payments with credit assets.
USD := microstellar.NewAsset("USD", "ISSUERSEED", microstellar.Credit4Type)
ms.Pay("source_seed", "target_address", "3", USD, microstellar.Opts().WithMemoText("for shelter"))
Pay also lets you make path payments. E.g., Mary pays Bob 2000 INR with XLM (lumens), using the path XLM -> USD -> EUR -> INR, spending no more than 20 XLM (lumens.)
XLM := microstellar.NativeAsset
USD := microstellar.NewAsset("USD", "ISSUERSEED", microstellar.Credit4Type)
EUR := microstellar.NewAsset("EUR", "ISSUERSEED", microstellar.Credit4Type)
INR := microstellar.NewAsset("INR", "ISSUERSEED", microstellar.Credit4Type)
ms.Pay("marys_seed", "bobs_address", "2000", INR,
microstellar.Opts().WithAsset(XLM, "20").Through(USD, EUR).WithMemoText("take your rupees!"))
If you don't know what path to take ahead of time, use Options.FindPathFrom(sourceAddress) to find a path for you.
ms.Pay("marys_seed", "bobs_address", "2000", INR,
microstellar.Opts().WithAsset(XLM, "20").Through(USD, EUR).FindPathFrom("marys_address"))
Example ¶
This example makes a payment of a credit asset from one account to another.
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Custom USD asset issued by specified issuer
USD := NewAsset("USD", "GAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ", Credit4Type)
// Pay 1 USD to targetAddress
err := ms.Pay("SAED4QHN3USETFHECASIM2LRI3H4QTVKZK44D2RC27IICZPZQEGXGXFC", "GAGTJGMT55IDNTFTF2F553VQBWRBLGTWLU4YOOIFYBR2F6H6S4AEC45E", "1", USD)
if err != nil {
log.Fatalf("Pay: %v", ErrorString(err))
}
fmt.Printf("ok")
Output: ok
Example (Memotext) ¶
Payments with memotext and memoid
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Custom USD asset issued by specified issuer
USD := NewAsset("USD", "GALC5V4UUUICHENN3ZZLQY6UWAC67CMKVXYT4MT7YGQRD6RMXXCAMHP6", Credit4Type)
// Pay 1 USD to targetAddress and set the memotext field
err := ms.Pay("SAED4QHN3USETFHECASIM2LRI3H4QTVKZK44D2RC27IICZPZQEGXGXFC", "GAGTJGMT55IDNTFTF2F553VQBWRBLGTWLU4YOOIFYBR2F6H6S4AEC45E", "1", USD, Opts().WithMemoText("boo"))
if err != nil {
log.Fatalf("Pay (memotext): %v", ErrorString(err))
}
// Pay 1 USD to targetAddress and set the memotext field
err = ms.Pay("SAED4QHN3USETFHECASIM2LRI3H4QTVKZK44D2RC27IICZPZQEGXGXFC", "GAGTJGMT55IDNTFTF2F553VQBWRBLGTWLU4YOOIFYBR2F6H6S4AEC45E", "1", USD, Opts().WithMemoID(42))
if err != nil {
log.Fatalf("Pay (memoid): %v", ErrorString(err))
}
fmt.Printf("ok")
Output: ok
Example (Multisig) ¶
Makes a multisignature payment
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Custom USD asset issued by specified issuer
USD := NewAsset("USD", "GAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ", Credit4Type)
// Pay 1 USD to targetAddress and set the memotext field
err := ms.Pay("SDKORMIXFL2QW2UC3HWJ4GKL4PYFUMDOPEJMGWVQBW4GWJ5W2ZBOGRSZ", "GAGTJGMT55IDNTFTF2F553VQBWRBLGTWLU4YOOIFYBR2F6H6S4AEC45E", "1", USD,
Opts().WithMemoText("multisig").
WithSigner("SAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ").
WithSigner("SBIUIQNMSXTGR4TGZETSQCGBTIF32G2L5D4AML4LFTMTHKM44UABFDMS"))
if err != nil {
log.Fatalf("Pay (memotext): %v", ErrorString(err))
}
// Pay 1 USD to targetAddress and set the memotext field
err = ms.Pay("SAED4QHN3USETFHECASIM2LRI3H4QTVKZK44D2RC27IICZPZQEGXGXFC", "GAGTJGMT55IDNTFTF2F553VQBWRBLGTWLU4YOOIFYBR2F6H6S4AEC45E", "1", USD, Opts().WithMemoID(73223))
if err != nil {
log.Fatalf("Pay (memoid): %v", ErrorString(err))
}
fmt.Printf("ok")
Output: ok
Example (Path) ¶
This example makes a path payment from XLM to INR via USD and EUR.
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
XLM := NativeAsset
// Custom USD, EUR, and INR assets issued by Bank of America
USD := NewAsset("USD", "GAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ", Credit4Type)
EUR := NewAsset("EUR", "GAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ", Credit4Type)
INR := NewAsset("INR", "GAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ", Credit4Type)
// Pay 5000 INR with XLM, going through USD and EUR. Spend no more than 40 lumens on this
// transaction.
err := ms.Pay(
"SAED4QHN3USETFHECASIM2LRI3H4QTVKZK44D2RC27IICZPZQEGXGXFC", // from
"GAGTJGMT55IDNTFTF2F553VQBWRBLGTWLU4YOOIFYBR2F6H6S4AEC45E", // to
"5000", INR, // they receive 5000 INR
Opts().
WithAsset(XLM, "40"). // we spend no more than 40 XLM
Through(USD, EUR)) // go through USD and EUR
if err != nil {
log.Fatalf("Pay: %v", ErrorString(err))
}
fmt.Printf("ok")
Output: ok
func (*MicroStellar) PayNative ¶
func (ms *MicroStellar) PayNative(sourceSeed string, targetAddress string, amount string, options ...*Options) error
PayNative makes a native asset payment of amount from source to target.
Example ¶
This example makes a native asset (lumens) payment from one account to another.
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Pay 1 XLM to targetAddress
err := ms.PayNative("SAED4QHN3USETFHECASIM2LRI3H4QTVKZK44D2RC27IICZPZQEGXGXFC", "GDS2DXCCTW5VO5A2KCEBHAP3W4XOCJSI2QVHNN63TXVGBUIIW4DI3BCW", "1")
if err != nil {
log.Fatalf("PayNative: %v", ErrorString(err))
}
fmt.Printf("ok")
Output: ok
func (*MicroStellar) RemoveSigner ¶
func (ms *MicroStellar) RemoveSigner(sourceSeed string, signerAddress string, options ...*Options) error
RemoveSigner removes signerAddress as a signer from sourceSeed's account.
Example ¶
This example removes a signer from an account.
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Remove signer from account
err := ms.RemoveSigner("SCSMBQYTXKZYY7CLVT6NPPYWVDQYDOQ6BB3QND4OIXC7762JYJYZ3RMK", "GCCRUJJGPYWKQWM5NLAXUCSBCJKO37VVJ74LIZ5AQUKT6KPVCPNAGC4A")
if err != nil {
log.Fatalf("RemoveSigner: %v", err)
}
fmt.Printf("ok")
Output: ok
func (*MicroStellar) RemoveTrustLine ¶
func (ms *MicroStellar) RemoveTrustLine(sourceSeed string, asset *Asset, options ...*Options) error
RemoveTrustLine removes an trustline from sourceSeed to an asset.
Example ¶
This example removes a trust line to a credit asset.
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Custom USD asset issued by specified issuer
USD := NewAsset("USD", "GAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ", Credit4Type)
// Remove the trustline (if exists)
err := ms.RemoveTrustLine("SCSMBQYTXKZYY7CLVT6NPPYWVDQYDOQ6BB3QND4OIXC7762JYJYZ3RMK", USD)
if err != nil {
log.Fatalf("RemoveTrustLine: %v", err)
}
fmt.Printf("ok")
Output: ok
func (*MicroStellar) Resolve ¶
func (ms *MicroStellar) Resolve(address string) (string, error)
Resolve looks up a federated address
func (*MicroStellar) SetFlags ¶
func (ms *MicroStellar) SetFlags(sourceSeed string, flags AccountFlags, options ...*Options) error
SetFlags changes the flags for the account.
Example ¶
This example sets flags on an issuer's account
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Set the AUTH_REQUIRED and AUTH_REVOCABLE flags on the account.
err := ms.SetFlags("SCSMBQYTXKZYY7CLVT6NPPYWVDQYDOQ6BB3QND4OIXC7762JYJYZ3RMK", FlagAuthRequired|FlagAuthRevocable)
if err != nil {
log.Fatalf("SetFlags: %v", err)
}
fmt.Printf("ok")
Output: ok
func (*MicroStellar) SetHomeDomain ¶
func (ms *MicroStellar) SetHomeDomain(sourceSeed string, domain string, options ...*Options) error
SetHomeDomain changes the home domain of sourceSeed.
Example ¶
This example sets the home domain for an account
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Set the home domain to qubit.sh
err := ms.SetHomeDomain("SCSMBQYTXKZYY7CLVT6NPPYWVDQYDOQ6BB3QND4OIXC7762JYJYZ3RMK", "qubit.sh")
if err != nil {
log.Fatalf("SetHomeDomain: %v", err)
}
fmt.Printf("ok")
Output: ok
func (*MicroStellar) SetMasterWeight ¶
func (ms *MicroStellar) SetMasterWeight(sourceSeed string, weight uint32, options ...*Options) error
SetMasterWeight changes the master weight of sourceSeed.
Example ¶
This example sets the weight of the accounts primary signer (the master weight) to zero. This effectively kills the account.
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Set master weight to zero.
err := ms.SetMasterWeight("SCSMBQYTXKZYY7CLVT6NPPYWVDQYDOQ6BB3QND4OIXC7762JYJYZ3RMK", 0)
if err != nil {
log.Fatalf("SetMasterWeight: %v", err)
}
// Load the account and check its master weight
account, err := ms.LoadAccount("GCCRUJJGPYWKQWM5NLAXUCSBCJKO37VVJ74LIZ5AQUKT6KPVCPNAGC4A")
if err != nil {
log.Fatalf("LoadAccount: %v", err)
}
log.Printf("Master weight: %v", account.GetMasterWeight())
fmt.Printf("ok")
Output: ok
func (*MicroStellar) SetThresholds ¶
func (ms *MicroStellar) SetThresholds(sourceSeed string, low, medium, high uint32, options ...*Options) error
SetThresholds sets the signing thresholds for the account.
Example ¶
This example sets the signing thresholds for an account
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Set the low, medium, and high thresholds for an account
err := ms.SetThresholds("SCSMBQYTXKZYY7CLVT6NPPYWVDQYDOQ6BB3QND4OIXC7762JYJYZ3RMK", 2, 2, 2)
if err != nil {
log.Fatalf("SetThresholds: %v", err)
}
fmt.Printf("ok")
Output: ok
func (*MicroStellar) UpdateOffer ¶ added in v0.2.1
func (ms *MicroStellar) UpdateOffer(sourceSeed string, offerID string, sellAsset *Asset, buyAsset *Asset, price string, sellAmount string, options ...*Options) error
UpdateOffer updates the existing offer with ID offerID on the DEX.
Example ¶
This example updates an existing offer on the DEX.
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Custom USD asset issued by specified issuer
USD := NewAsset("USD", "GAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ", Credit4Type)
// Update Offer ID 23456 to sell 200 USD on the DEX for lumens (at 1 lumen / USD.)
err := ms.UpdateOffer("SCSMBQYTXKZYY7CLVT6NPPYWVDQYDOQ6BB3QND4OIXC7762JYJYZ3RMK",
"23456", USD, NativeAsset, "1", "200")
if err != nil {
log.Fatalf("UpdateOffer: %v", err)
}
fmt.Printf("ok")
Output: ok
func (*MicroStellar) WatchPayments ¶
func (ms *MicroStellar) WatchPayments(address string, options ...*Options) (*PaymentWatcher, error)
WatchPayments watches the ledger for payments to and from address and streams them on a channel . Use Options.WithContext to set a context.Context, and Options.WithCursor to set a cursor.
Example ¶
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Watch for payments to address. (The fake network sends payments every 200ms.)
watcher, err := ms.WatchPayments("GCCRUJJGPYWKQWM5NLAXUCSBCJKO37VVJ74LIZ5AQUKT6KPVCPNAGC4A",
Opts().WithContext(context.Background()))
if err != nil {
log.Fatalf("Can't watch ledger: %+v", err)
}
// Count the number of payments received.
paymentsReceived := 0
go func() {
for p := range watcher.Ch {
paymentsReceived++
log.Printf("WatchPayments %d: %v -- %v %v from %v to %v\n", paymentsReceived, p.Type, p.Amount, p.AssetCode, p.From, p.To)
}
log.Printf("## WatchPayments ## Done -- Error: %v\n", *watcher.Err)
}()
// Stream the ledger for about a second then stop the watcher.
time.Sleep(1 * time.Second)
watcher.Done()
// Sleep a bit to wait for the done message from the goroutine.
time.Sleep(500 * time.Millisecond)
fmt.Printf("%d payments received", paymentsReceived)
Output: 5 payments received
type OfferParams ¶ added in v0.2.1
type OfferParams struct {
// Create, update, or delete.
OfferType OfferType
// The asset that's being sold on the DEX.
SellAsset *Asset
// The asset that you want to buy on the DEX.
BuyAsset *Asset
// How much you're willing to pay (in BuyAsset units) per unit of SellAsset.
Price string
// How many units of SellAsset are you selling?
SellAmount string
// Existing offer ID (for Update and Delete)
OfferID string
}
OfferParams specify the parameters
type OfferType ¶ added in v0.2.1
type OfferType int
OfferType tells ManagedOffer what operation to perform
type Options ¶ added in v0.2.1
type Options struct {
// contains filtered or unexported fields
}
Options are additional parameters for a transaction. Use Opts() or NewOptions() to create a new instance.
func NewOptions ¶ added in v0.2.1
func NewOptions() *Options
NewOptions creates a new options structure for Tx.
func (*Options) FindPathFrom ¶ added in v0.2.4
FindPathFrom enables automatic path finding for path payments. Use sourceAddress to specify the address (not seed) for the source account.
func (*Options) MakePassive ¶ added in v0.2.1
MakePassive turns this into a passive offer. Used with LoadOffers.
func (*Options) Through ¶ added in v0.2.2
Through adds "asset" as a routing point in the payment path.
E.g.,
ms.Pay(sourceSeed, address, "20", INR, Opts().WithAsset(NativeAsset, "20").Through(USD, EUR)
func (*Options) WithAsset ¶ added in v0.2.2
WithAsset is used to setup a path payment. This makes the Pay method use "asset" as the sending asset, and sends no more than maxAmount units of the asset. Used with Pay and FindPaths.
E.g.,
ms.Pay(sourceSeed, address, "20", INR, Opts().WithAsset(NativeAsset, "20").Through(USD, EUR)
func (*Options) WithContext ¶ added in v0.2.1
WithContext sets the context.Context for the connection. Used with Watch* methods.
func (*Options) WithCursor ¶ added in v0.2.1
WithCursor sets the cursor for watchers and queries. Used with Watch* methods and LoadOffers.
func (*Options) WithLimit ¶ added in v0.2.1
WithLimit sets the limit for queries. Used with LoadOffers.
func (*Options) WithMemoID ¶ added in v0.2.1
WithMemoID sets the memoType and memoID fields on a Payment. Used with all transactions.
func (*Options) WithMemoText ¶ added in v0.2.1
WithMemoText sets the memoType and memoText fields on a Payment. Used with all transactions.
func (*Options) WithSigner ¶ added in v0.2.1
WithSigner adds a signer to Payment. Used with all transactions.
func (*Options) WithSortOrder ¶ added in v0.2.1
WithSortOrder sets the sort order of the results. Used with LoadOffers.
type Params ¶
type Params map[string]interface{}
Params lets you add optional parameters to New and NewTx.
type Path ¶ added in v0.2.4
type Path struct {
DestAsset *Asset
DestAmount string
SourceAsset *Asset
SourceAmount string
Hops []*Asset
}
Path is a microstellar payment path
type PathResponse ¶ added in v0.2.4
type PathResponse struct {
Links struct {
Self Link `json:"self"`
Next Link `json:"next"`
Prev Link `json:"prev"`
} `json:"_links"`
Embedded struct {
Records []HorizonPath `json:"records"`
} `json:"_embedded"`
}
PathResponse is what the horizon server returns
type Payment ¶
Payment represents a finalized payment in the ledger. You can subscribe to payments on the stellar network via the WatchPayments call.
func NewPaymentFromHorizon ¶
NewPaymentFromHorizon converts a horizon JSON payment struct to Payment
type PaymentWatcher ¶
type PaymentWatcher struct {
// Ch gets a *Payment everytime there's a new entry in the ledger.
Ch chan *Payment
// Call Done to stop watching the ledger. This closes Ch.
Done func()
// This is set if the stream terminates unexpectedly. Safe to check
// after Ch is closed.
Err *error
}
PaymentWatcher is returned by WatchPayments, which watches the ledger for payments to and from an address.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx represents a unique stellar transaction. This is used by the MicroStellar library to abstract away the Horizon API and transport. To reuse Tx instances, you must call Tx.Reset() between operations.
This struct is not thread-safe by design -- you must use separate instances in different goroutines.
Unless you're hacking around in the guts, you should not need to use Tx.
func NewTx ¶
NewTx returns a new Tx that operates on the network specified by networkName. The supported networks are:
public: the public horizon network test: the public horizon testnet fake: a fake network used for tests custom: a custom network specified by the parameters
If you're using "custom", provide the URL and Passphrase to your horizon network server in the parameters.
NewTx("custom", Params{
"url": "https://my-horizon-server.com",
"passphrase": "foobar"})
func (*Tx) Build ¶
func (tx *Tx) Build(sourceAccount build.TransactionMutator, muts ...build.TransactionMutator) error
Build creates a new operation out of the provided mutators.
func (*Tx) Reset ¶
func (tx *Tx) Reset()
Reset clears all internal sate, so you can run a new operation.
func (*Tx) WithOptions ¶
WithOptions sets the Tx options and returns the Tx
type TxOptions ¶
type TxOptions Options
TxOptions is a deprecated alias for TxOptoins
Example (Memotext) ¶
Payments with memotext and memoid
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Custom USD asset issued by specified issuer
USD := NewAsset("USD", "GALC5V4UUUICHENN3ZZLQY6UWAC67CMKVXYT4MT7YGQRD6RMXXCAMHP6", Credit4Type)
// Pay 1 USD to targetAddress and set the memotext field
err := ms.Pay("SAED4QHN3USETFHECASIM2LRI3H4QTVKZK44D2RC27IICZPZQEGXGXFC", "GAGTJGMT55IDNTFTF2F553VQBWRBLGTWLU4YOOIFYBR2F6H6S4AEC45E", "1", USD, Opts().WithMemoText("boo"))
if err != nil {
log.Fatalf("Pay (memotext): %v", ErrorString(err))
}
// Pay 1 USD to targetAddress and set the memotext field
err = ms.Pay("SAED4QHN3USETFHECASIM2LRI3H4QTVKZK44D2RC27IICZPZQEGXGXFC", "GAGTJGMT55IDNTFTF2F553VQBWRBLGTWLU4YOOIFYBR2F6H6S4AEC45E", "1", USD, Opts().WithMemoID(42))
if err != nil {
log.Fatalf("Pay (memoid): %v", ErrorString(err))
}
fmt.Printf("ok")
Output: ok
Example (Multisig) ¶
Makes a multisignature payment
// Create a new MicroStellar client connected to a fake network. To
// use a real network replace "fake" below with "test" or "public".
ms := New("fake")
// Custom USD asset issued by specified issuer
USD := NewAsset("USD", "GAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ", Credit4Type)
// Pay 1 USD to targetAddress and set the memotext field
err := ms.Pay("SDKORMIXFL2QW2UC3HWJ4GKL4PYFUMDOPEJMGWVQBW4GWJ5W2ZBOGRSZ", "GAGTJGMT55IDNTFTF2F553VQBWRBLGTWLU4YOOIFYBR2F6H6S4AEC45E", "1", USD,
Opts().WithMemoText("multisig").
WithSigner("SAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ").
WithSigner("SBIUIQNMSXTGR4TGZETSQCGBTIF32G2L5D4AML4LFTMTHKM44UABFDMS"))
if err != nil {
log.Fatalf("Pay (memotext): %v", ErrorString(err))
}
// Pay 1 USD to targetAddress and set the memotext field
err = ms.Pay("SAED4QHN3USETFHECASIM2LRI3H4QTVKZK44D2RC27IICZPZQEGXGXFC", "GAGTJGMT55IDNTFTF2F553VQBWRBLGTWLU4YOOIFYBR2F6H6S4AEC45E", "1", USD, Opts().WithMemoID(73223))
if err != nil {
log.Fatalf("Pay (memoid): %v", ErrorString(err))
}
fmt.Printf("ok")
Output: ok