NFT Gen 2 Tech Doc
  • Introduction
  • Overview
    • NFT Data Chain
    • Cosmos SDK
    • Modules
      • Core Module
      • Oracle
  • Integration
    • Creating Schema
    • System Mode
      • Minting
      • Sending Action
    • User Mode
      • Minting
      • Sending Action
  • Data-chain Base URI
  • Getting Started
    • Installation (Golang)
    • Getting Started
      • Download Binary
      • Developer Resources
      • Binary Overview
      • Create Account
      • Faucet
      • Deploy NFT Gen2
      • Perform Action of NFT Gen2
      • Update NFT Schema
      • Script
    • SDK Package for NodeJs
      • Example Resources
      • Deploy NFT Gen2
      • Perform Action of NFT Gen2
      • Update NFT Schema
    • SDK for GO
      • Requirements
      • Installation
      • Usage
      • Preparing Key for Authentication
      • Supported Messages and Queries
      • Examples
    • Six Protocol Developer Community
Powered by GitBook
On this page
  • Creating Client
  • Broadcast Mode
  • Construct Message
  • Broadcast Transaction
  • Query
  • go.mod
  1. Getting Started
  2. SDK for GO

Usage

To use the SDK in your Golang project, you must first import it:

import s6 "github.com/thesixnetwork/six-protocol-go-sdk/api"

Creating Client

gasPrice := "1.25usix" // default "1.25usix"
clientOptions := &s6.ClientOptions{
	BroadcastMode: "<broadcast-mode>", // default "block"
	GasPrices:     &gasPrice,
}
client, err := s6.NewClient(
	"<nodeURL>",
	"<armor>",
	"<passphrase>",
	"<chain-id>",
	clientOptions,
)
if err != nil {
	fmt.Println(err)
	return
}

Broadcast Mode

sync: Wait for the transaction to pass/fail the CheckTx async: Do not wait for the transaction to pass/fail the CheckTx. Instead, send and return the transaction immediately. block: Wait for the transaction to pass/fail the CheckTx, DeliverTx, and be committed to a block. (Note: this is not recommended.)

nodeURL: Endpoint URL for SIX Protocol fivenet: https://rpc1.fivenet.sixprotocol.net sixnet: https://sixnet-rpc.sixprotocol.net armor: An encrypted private key use with passphrase as a secret key. passphrase: Together with encrypted private key is used as a secret key. Here is the detail about how to create both armor and passphrase. chain-id: For testnet , the chain id is "fivenet" and "sixnet" for Testnet and Mainnet

Construct Message

Create a message for each service that you need to use. You can find more messages here

import nftmngrtypes "github.com/thesixnetwork/sixnft/x/nftmngr/types"
msg := &nftmngrtypes.MsgPerformActionByAdmin{
	Creator:       client.ConnectedAddress,
	NftSchemaCode: "nft-schema-code",
	TokenId:       "<token-id>",
	Action:        "<action-name>",
	RefId:         "<ref-idL>",
	Parameters:    []*nftmngrtypes.ActionParameter{},
}

Broadcast Transaction

txResponse, err := client.GenerateOrBroadcastTx(msg)

Query

To query the data , you can use read-to-use query client from the constructed client. And for more detail about queries you can use , here is the list.

queryClient := client.QueryClient()

go.mod

You would need to put the line below at the bottom of your go.mod

replace github.com/gogo/protobuf v1.3.3 => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
PreviousInstallationNextPreparing Key for Authentication

Last updated 2 years ago