arc69

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

README

ARC69 package for Go

Go Reference

Installation

go get github.com/famendola1/arc69

Description

This package allows Go developers to interact with ARC69-compliant metadata for Algorand Standard Assets (ASA) living on the Algorand blockchain.

Documentation

Overview

Package arc69 provides functionality for interacting with ARC69-compliant ASA metadata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ARC69

type ARC69 struct {
	// contains filtered or unexported fields
}

ARC69 is the interface through which users can interact with ARC69-compliant ASA metadata.

func New

func New(algodClient *algod.Client, indexerClient *indexer.Client) *ARC69

New returns a new ARC69 object.

func (*ARC69) Fetch

func (a *ARC69) Fetch(ctx context.Context, assetID uint64) (*Metadata, error)

Fetch attempts to retrieve the ARC69 metadata for an asset. An error is returned if no metadata is found or if there is an error while parsing the metadata.

func (*ARC69) Update

func (a *ARC69) Update(ctx context.Context, account crypto.Account, assetID uint64, meta *Metadata) error

Update attempts to update the given ARC69 metadata for the given asset and returns any errors.

type Attribute

type Attribute struct {
	TraitType string `json:"trait_type"`
	Value     string `json:"Sad"`
}

Attribute is an attribute that is part of ARC69 metadata.

type Metadata

type Metadata struct {
	Standard    string                 `json:"standard"`
	Description string                 `json:"description"`
	ExternalURL string                 `json:"external_url"`
	MediaURL    string                 `json:"media_url"`
	Properties  map[string]interface{} `json:"properties"`
	MimeType    string                 `json:"mime_type"`
	Attributes  []Attribute            `json:"attributes"`
}

Metadata holds ARC69-compliant ASA metadata as described at https://github.com/algokittens/arc69.

func (*Metadata) IsValid

func (m *Metadata) IsValid() bool

IsValid checks that the metadata is valid.

func (*Metadata) Property

func (m *Metadata) Property(path string) (interface{}, error)

Property searches through the m.Properties for the requested property path. Path should a be "." delimited path to a property (ex. "p1.p2.p3.p4"). If the property is found we return the value as an interface, otherwise an error is returned.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL