golang client for interacting with audius
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)
}
}
git clone https://github.com/alecsavvy/gaudius.git
make example tx-subscriber
- 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))
}
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)
}
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
- playlists
- reactions
- search
- tips
- tracks
- transactions
- users
- uploads
- blob
- image
- delist
- developer apps
- playlists
- resolve
- tips
- tracks
- users