-
Notifications
You must be signed in to change notification settings - Fork 6
Transaction Transfer
Alexander Popov edited this page Jun 12, 2019
·
12 revisions
Transfer transaction is used to send assets between two accounts. It can hold a message of length 1024. To create Transfer Transaction use NewTransferTransaction().
- Following parameters required:
- Recipient - The address of the recipient account.
- Mosaics - The array of mosaics to be sent.
- Message - The transaction message of 1024 characters.
package main
import (
"context"
"fmt"
"time"
"github.com/proximax-storage/go-xpx-catapult-sdk/sdk"
)
const (
// Types of network.
networkType = sdk.MijinTest
// A valid private key
privateKey = "3B9670B5CB19C893694FC49B461CE489BF9588BE16DBE8DC29CF06338133DEE6"
)
func main() {
conf, err := sdk.NewConfig(baseUrl, networkType, time.Second * 10)
if err != nil {
fmt.Printf("NewConfig returned error: %s", err)
return
}
// Use the default http client
client := sdk.NewClient(nil, conf)
// Create an account from a private key
account, err := sdk.NewAccountFromPrivateKey(privateKey, networkType)
if err != nil {
fmt.Printf("NewAccountFromPrivateKey returned error: %s", err)
return
}
// Create a new transfer type transaction
transaction, err := sdk.NewTransferTransaction(
// The maximum amount of time to include the transaction in the blockchain.
sdk.NewDeadline(time.Hour * 1),
// The address of the recipient account.
sdk.NewAddress("SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC", networkType),
// The array of mosaic to be sent.
[]*sdk.Mosaic{sdk.Xpx(10000000)},
// The transaction message of 1024 characters.
sdk.NewPlainMessage("Here you go"),
networkType,
)
if err != nil {
fmt.Printf("NewTransferTransaction returned error: %s", err)
return
}
// Sign transaction
signedTransaction, err := account.Sign(transaction)
if err != nil {
fmt.Printf("Sign returned error: %s", err)
return
}
// Announce transaction
_, err = client.Transaction.Announce(context.Background(), signedTransaction)
if err != nil {
fmt.Printf("Transaction.Announce returned error: %s", err)
return
}
}
- Home
- Installation
-
Examples
- Basic functions
- Get Accounts info
- Get Transactions info
- Get Mosaic info
- Get Mosaic Levy info
- Get Namespace info
- Get BlockChain info
- Get Network info
- Get Metadata info
- Get Nem Metadata info
- Get Account Properties info
- Get Exchange info
- Get SDA-SDA Exchange info
- Get Secret lock info
- Get Storage info
- Announces a transaction
- Websocket