Git Product home page Git Product logo

tinyman-mobile-sdk's Introduction

tinyman-mobile-sdk

Overview

This is a mobile SDK providing access to the Tinyman AMM on the Algorand blockchain. It currently supports V1.1 Tinyman. This SDK is a wrapper for https://github.com/synycboom/tinyman-go-sdk (In case you are looking for Golang SDK).

Installation

You can download libraries for iOS and Android from releases page.

Folder overview

example/ios contains example usage of iOS

example/android contains example usage of Android

tinyman provides wrappers for tinyman-go-sdk and some wrapped algorand-go-sdk functions

misc contains a release script

Video Demo

https://youtu.be/tDIdXhrh7ks

Usage

See example for how to integrate this SDK with both iOS and Android.

Usage Limitation

Since this SDK is compiled from Go to mobile native libs, there are some limitations that this SDK cannot do.

  • go-mobile has type restriction, so other unsupported types (from exported functions/parameters/returned values) are not able to be bundled to the libs.
  • we have to create wrappers for the algorand-go-sdk such as the client, and other structs/functions and use them with this SDK, but it is not fully ported yet. because it requires a lot of effort to do.
  • features that require algorand-go-sdk structs/functions like signing with kmd client kmd-client is not available right now.
  • Some types used in tinyman-go-sdk like uint64, float64, or a slice of structs that are not []byte are not supported. We will use a string for uint64/float64 and an iterator for a slice and convert them inside the SDK.

Basic Usage

Normally, the steps for calling the SDK are separated into 3 parts.

  • call a prepareXXXX function to prepare transactions that you want
  • sign transactions returned by the prepareXXXX function, will usually be signed by user account (other transactions will be signed by logic signature account inside the prepareXXXX function)
  • submit transactions to the blockchain and wait for confirmation

Supported Features

  • Bootstrapping
  • Minting
  • Burning
  • Swapping
  • Redeeming
  • OptInApp
  • OptInAsset

Supposing that we want to bootstrap a liquidity pool

  1. prepare bootstrap transactions

Android

// Fetch the asset1 token
val token = tinymanClient.fetchAsset(asset1Id)

// Fetch the ALGO token
val algo = tinymanClient.fetchAsset("0")

// Fetch the created pool
val pool = tinyman.Pool(
    algodClient,
    token,
    algo,
    null,
    tinymanClient.validatorAppID,
    account.address,
    true
)

// Prepare a transaction group for bootstrapping
// Note that some transactions need to be signed with LogicSig account, and they were signed in the function.
val txGroup = pool.prepareBootstrapTransactions(account.address)

iOS

var error: NSError?

// Fetch the asset1 token
let token = try tinymanClient.fetchAsset(asset1Id)

// Fetch the ALGO token
let algo = try tinymanClient.fetchAsset("0")

// Fetch the created pool
let pool = TinymanNewPool(
    algodClient,
    token,
    algo,
    nil,
    tinymanClient.getValidatorAppID(),
    account.getAddress(),
    true,
    &error
)!
if (error != nil) {
    throw error!
}

// Prepare a transaction group for bootstrapping
// Note that some transactions need to be signed with LogicSig account, and they were signed in the function.
let txGroup = try pool.prepareBootstrapTransactions(account.getAddress())
  1. sign transactions

Android

txGroup.sign(account)

iOS

try txGroup.sign(account)
  1. submit transactions

Android

val txId = tinymanClient.submit(txGroup, true)

iOS

let txId = tinymanClient.submit(txGroup, wait: true, error: &error)
if (error != nil) {
    throw error!
}

Running example

Open the example project with Android Studio or Xcode.

For contributors

You can prepare environment for android development by running the following command. It will install an SDK and NDK in the current directory.

# in case you use linux
$ make development.linux

# in case you use mac
$ make development.osx

$ make init

You can run make build.ios or make build.android to build the SDK. It will automatically save the output to example directory.

You can run make release to build a release version of the SDK and zip all the files.

Disclaimer

Nothing in the repo constitutes professional and/or financial advice. Use this SDK at your own risk.

tinyman-mobile-sdk's People

Contributors

synycboom avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.