Skip to content

The Mobius Go (Golang) Client provides simple access to the Mobius API for applications written in Go

License

Notifications You must be signed in to change notification settings

HakaseLabs/mobius-go

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mobius Go API Client

GoDoc

The Mobius Go (Golang) Client provides simple access to the Mobius API for applications written in Go

Installation

Install with go get

$ go get github.com/codehakase/mobius-go

QuickStart

To use the library, you'd need to create a client, with your Mobius appuid and apikey.

package main

import (
  "github.com/codehakase/mobius-go"
  "fmt"
)

func main() {
  mc := mobius.New(yourApiKey, yourAppUID)

  // Retrive a struct to communicate with the DApp store
  appStore := mc.AppStore

  // Get a user's balance
  usrBal, err := appStore.Balance("myemail@example.com")
  if err != nil {
    log.Fatalf("can't fetch user's balance, err: %+v", err)
    return
  }
  fmt.Println("User got %d mobi credits available", usrBal.NumCredits)

  // Credit user with mobi credits
  if fundUser, err := appStore.Credit("user@example.com", 1000); err != nil {
    log.Fatalf("could not fund user, err: %+v", err)
    return
  }
  // Use 20 Mobi Credits from user@example.com
  if charge, err := appStore.Use("user@example.com", 20); err == nil {
    if charge.Success {
      fmt.Printf("User has been charged, and is left with %d mobi credits", charge.NumCredits)
    }
  } else {
    log.Fatalf("could not charge user, err: %+v", err)
  }
}

Methods

  • mobius.AppStore.Balance( email )

    Get balance of credits for email.

  • mobius.AppStore.Use( email, numCredits )

    Use numCredits from user with email.

  • mobius.Tokens.Register( tokenType, name, symbol, address )

    Register a token.

  • mobius.Tokens.Balance( tokenUid, address )

    Query the number of tokens specified by the token.

  • mobius.Tokens.CreateAddress( tokenUid, managed )

    Create an address for the token.

  • mobius.Tokens.RegisterAddress( tokenUid, address )

    Register an address for the token.

  • mobius.Tokens.TransferInfo( tokenAddressTransferUid )

    Get the status and transaction hash of a Mobius managed token transfer.

Other methods can be found in the API reference

API Reference

https://godoc.org/github.com/codehakase/mobius-go Mobius API Docs - https://mobius.network/docs/

TODOs

  • Integration Testing
  • CLI Tool

About

The Mobius Go (Golang) Client provides simple access to the Mobius API for applications written in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%