Skip to content

ever wanted to feel like a gaud and develop on audius?

Notifications You must be signed in to change notification settings

alecsavvy/gaudius

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gaudius 🎧🎵🎸🎤

golang client for interacting with audius

how to use

library

go get github.com/alecsavvy/gaudius
package main

import "github.com/alecsavvy/gaudius"

func main() {
	sdk, err := gaudius.NewSdk()
	if err != nil {
		log.Fatal("sdk init failed: ", err)
	}
}

examples

git clone https://github.com/alecsavvy/gaudius.git
make example tx-subscriber

completed apis

discovery query api

  • developer apps
  • playlists
  • resolve
  • tips
  • tracks
  • users
func main() {
	sdk, err := gaudius.NewSdk()
	if err != nil {
		log.Fatal(err)
	}

	user, err := sdk.GetUser("1PqKz")

	if err != nil {
		log.Fatal(err)
	}

	// print user to console
	fmt.Printf("%# v", pretty.Formatter(user))

	imgdata, err := sdk.GetImage("01H6EJC9XVMQXM7FA4P0AY148T")

	if err != nil {
		log.Fatal(err)
	}

	// print image to console
	img, _, err := image.Decode(bytes.NewReader(imgdata))
	converter := convert.NewImageConverter()
	opts := convert.DefaultOptions
	fmt.Println(converter.Image2ASCIIString(img, &opts))
}

transaction subscriber

This is an event stream of incoming transactions from audius through the ACDC network.

func main() {
	sdk, err := gaudius.NewSdk()
	if err != nil {
		log.Fatal(err)
	}
	scanner, stopper := sdk.EventSubscriber()

	events := []*contracts.EntityManagerManageEntity{}
	for event := range scanner {
		events = append(events, event)
		if len(events) == 5 {
			break
		}
	}
	close(stopper)

	fmt.Println("received five events!")
	spew.Dump(events)
}

contract interfaces

Generated go structures to interact with common Audius ethereum smart contracts.

func main() {
	url := os.Getenv("ETHEREUM_RPC")
	client, err := ethclient.Dial(url)
	if err != nil {
		log.Fatal(err)
	}

	addr := common.HexToAddress(gaudius.MainnetRegistryAddress)
	contractRegistry, err := contracts.NewRegistry(addr, client)
	if err != nil {
		log.Fatal(err)
	}

	audTokenAddr, err := contractRegistry.GetContract0(nil, gaudius.AudiusTokenKey)
	if err != nil {
		log.Fatal(err)
	}

	audioToken, err := contracts.NewAudiusToken(audTokenAddr, client)
	if err != nil {
		log.Fatal(err)
	}

	totalSupply, err := audioToken.TotalSupply(nil)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Total audio token supply: %d\n", totalSupply)
}

see more in the examples directory

in progress apis

discovery query full api

  • playlists
  • reactions
  • search
  • tips
  • tracks
  • transactions
  • users

content public api

  • uploads
  • blob
  • image
  • delist

discovery write api

  • developer apps
  • playlists
  • resolve
  • tips
  • tracks
  • users

About

ever wanted to feel like a gaud and develop on audius?

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published