Categorygithub.com/alecsavvy/gaudius
modulepackage
0.0.0-20240215034504-75cb85661766
Repository: https://github.com/alecsavvy/gaudius.git
Documentation: pkg.go.dev

# README

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

# Packages

No description provided by the author
No description provided by the author

# Functions

this is because the swagger spec has a string for a number iat and fails to serialize also, claims aren't marshallable.
No description provided by the author
No description provided by the author
takes in english dimensions like "small"/"large" and converts to common content node numeric dimensions defaults to large image should size be invalid.
formats to "dimensionXdimension" for content nodes.
instantiates audius contract manager so that contracts can be initialized lazily.
instantiates audius contract manager and eagerly gathers contract instances as well.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
initializes a new sdk against mainnet.
No description provided by the author
No description provided by the author
No description provided by the author
for parity with the web3.js web3.utils.utf8ToHex() call.

# Variables

env var keys.
env var keys.
env var keys.
contract keys.
contract keys.
contract keys.
devnet.
environments.
env var keys.
Genre constants from the audius-protocol repository https://github.com/AudiusProject/audius-protocol/blob/23edd8144acc13da2b8d9000f2245e038b438874/packages/libs/src/sdk/types/Genre.ts#L4.
contract keys.
devnet.
environments.
contract addresses.
cached nodes to make selection faster on init.
cached nodes to make selection faster on init.
contract addresses.
mainnet.
production.
contract keys.
contract keys.
env var keys.
contract keys.
testnet.
testnet.
contract keys.
environments.
contract addresses.
cached nodes to make selection faster on init.
cached nodes to make selection faster on init.
contract addresses.

# Structs

manager struct so contracts get loaded lazily upon usage and don't spam rpcs for contracts a developer may not need.
the one struct to rule them all.
No description provided by the author
type that manages the selected content node.
structure that manages the selected discovery node.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
params for the subscriber function.