-
Notifications
You must be signed in to change notification settings - Fork 7
Get Metadata info
Alexander Popov edited this page Jun 4, 2019
·
7 revisions
- Param address - account Address
package main
import (
"context"
"fmt"
"github.com/proximax-storage/go-xpx-catapult-sdk/sdk"
)
const (
networkType = sdk.MijinTest
// Valid account address for Mijin Test network
address = "SCQALPC7AQHA6OEDCSOF45HEMLKIKFTSFISN2LVG"
// Valid key which is used to store metadata in address
key = "my_super_key"
)
func main() {
conf, err := sdk.NewConfig("http://localhost:3000", networkType)
if err != nil {
panic(err)
}
// Use the default http client
client := sdk.NewClient(nil, conf)
info, err := client.Metadata.GetMetadataByAddress(context.Background(), address)
if err != nil {
fmt.Printf("Metadata.GetMetadataByAddress returned error: %s", err)
return
}
fmt.Printf("Address %s\n", info.Address)
fmt.Printf("Address Metadata Type %b\n", sdk.MetadataAddressType == info.MetadataType)
fmt.Printf("Metadata for %s: %s\n", key, info.Fields[key])
// you can get info for multiple addresses at the same time also
// infos, err := client.Metadata.GetAddressMetadatasInfo(context.Background(), address1, address2)
}
- Param mosaic - id of mosaic
package main
import (
"context"
"fmt"
"github.com/proximax-storage/go-xpx-catapult-sdk/sdk"
)
const (
networkType = sdk.MijinTest
// Valid uint 32 nonce
nonce = ...
// Valid public key of mosaic owner
publicKey = "F5F090D5EC24E572CC9D4EC3B891D8C4435E986620CB38B003EA19EAD13AC724"
// Valid key which is used to store metadata in address
key = "my_super_key"
)
func main() {
conf, err := sdk.NewConfig("http://localhost:3000", networkType)
if err != nil {
panic(err)
}
// Use the default http client
client := sdk.NewClient(nil, conf)
// Generate mosaic id
mosaicId, err := sdk.NewMosaicIdFromNonceAndOwner(nonce, publicKey)
if err != nil {
panic(err)
}
info, err := client.Metadata.GetMetadataByMosaicId(context.Background(), mosaicId)
if err != nil {
fmt.Printf("Metadata.GetMetadataByMosaicId returned error: %s", err)
return
}
fmt.Printf("Mosaic id %s\n", info.MosaicId)
fmt.Printf("Mosaic Metadata Type %b\n", sdk.MetadataMosaicType == info.MetadataType)
fmt.Printf("Metadata for %s: %s\n", key, info.Fields[key])
// you can get info for multiple mosaics at the same time also
// infos, err := client.Metadata.GetMosaicMetadatasInfo(context.Background(), mosaicId1, mosaicId2)
}
- Param namespace - id of namespace
package main
import (
"context"
"fmt"
"github.com/proximax-storage/go-xpx-catapult-sdk/sdk"
)
const (
networkType = sdk.MijinTest
// Valid namespace name
namespaceName = "ticket"
// Valid key which is used to store metadata in address
key = "my_super_key"
)
func main() {
conf, err := sdk.NewConfig("http://localhost:3000", networkType)
if err != nil {
panic(err)
}
// Use the default http client
client := sdk.NewClient(nil, conf)
// Generate namespace id from name
namespaceId, err := sdk.NewNamespaceIdFromName(namespaceName)
if err != nil {
panic(err)
}
info, err := client.Metadata.GetMetadataByNamespaceId(context.Background(), namespaceId)
if err != nil {
fmt.Printf("Metadata.GetMetadataByNamespaceId returned error: %s", err)
return
}
fmt.Printf("Namespace id %s\n", info.NamespaceId)
fmt.Printf("Namespace Metadata Type %b\n", sdk.MetadataNamespaceType == info.MetadataType)
fmt.Printf("Metadata for %s: %s\n", key, info.Fields[key])
// you can get info for multiple mosaics at the same time also
// infos, err := client.Metadata.GetNamespaceMetadatasInfo(context.Background(), namespaceId1, namespaceId2)
}
- 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