Skip to content

Examples: Get Accounts info

Eleazar Garrido edited this page Oct 2, 2018 · 26 revisions

Get AccountInfo for an account.

package main

import (
	"encoding/json"
	"fmt"
	"github.com/proximax-storage/nem2-sdk-go/sdk"
	"golang.org/x/net/context"
)

// Simple Account API request
func main() {

	pk := "04dd376196603c44a19fd500492e5de12de9ed353de070a788cb21f210645613"

	address, _ := sdk.NewAddressFromPublicKey(pk, sdk.MijinTest)

	conf, err := sdk.LoadTestnetConfig("http://catapult.internal.proximax.io:3000")
	if err != nil {
		panic(err)
	}

	// Use the default http client
	client := sdk.NewClient(nil, conf)

	// Get AccountInfo for an account.
	// Param address - A Address struct.
	accountInfo, resp, err := client.Account.GetAccountInfo(context.Background(), address)
	if err != nil {
		fmt.Printf("Account.GetAccountInfo returned error: %s", err)
		return
	}
	accountInfoJson, _ := json.Marshal(accountInfo)
	fmt.Printf("Response Status Code == %d\n", resp.StatusCode)
	fmt.Printf("%s\n\n", string(accountInfoJson))
}

Get AccountsInfo for different accounts.