github.com/InjectiveLabs/sdk-go@v1.53.0/examples/exchange/portfolio/1_AccountPortfolio/example.go (about)

     1  package main
     2  
     3  import (
     4  	"context"
     5  	"encoding/json"
     6  	"fmt"
     7  
     8  	"github.com/InjectiveLabs/sdk-go/client/common"
     9  	exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange"
    10  )
    11  
    12  func main() {
    13  	// select network: local, testnet, mainnet
    14  	network := common.LoadNetwork("testnet", "lb")
    15  	exchangeClient, err := exchangeclient.NewExchangeClient(network)
    16  	if err != nil {
    17  		panic(err)
    18  	}
    19  
    20  	ctx := context.Background()
    21  	accountAddress := "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt"
    22  	res, err := exchangeClient.GetAccountPortfolioBalances(ctx, accountAddress)
    23  	if err != nil {
    24  		fmt.Println(err)
    25  	}
    26  
    27  	str, _ := json.MarshalIndent(res, "", " ")
    28  	fmt.Print(string(str))
    29  }