GithubHelp home page GithubHelp logo

trustsdk-ios's Introduction

TrustSDK

CI Status Version License Platform

Getting Started

The TrustSDK lets you sign Ethereum transactions and messages so that you can bulid a native DApp without having to worry about keys or wallets. Follw these instructions to integrate TrustSDK in your native DApp.

Demo

Sign Message and Transaction

Add dependency

TrustSDK is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'TrustSDK'

Run pod install.

Register a scheme for your app

Open Xcode an click on your project. Go to the 'Info' tab and expand the 'URL Types' group. Click on the + button to add a new scheme. Enter a custom scheme name in 'URL Scemes'.

Adding a scheme

Handle Trust callbacks

In your AppDelegate add import TrustSDK at the top and add let trustSDK = TrustSDK(callbackScheme: "trustexample") within the class definition. Remember to replace trustexample with your custom scheme.

Within your func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool method add this:

/// Handle wallet results
if let url = launchOptions?[.url] as? URL {
    return trustSDK.handleCallback(url: url)
}

Also implement the func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool method like this:

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
    /// Handle wallet results
    return trustSDK.handleCallback(url: url)
}

Sign a transaction

To sign a transaction use this code

trustSDK.signTransaction(transaction) { [weak self] signedTransaction in
    // Use signedTransaction
}

Sign a message

To sign a message use this code

trustSDK.signMessage(message) { [weak self] signedMessage in
    // Use signedMessage
}

Sign a personal message

To sign a message use this code

trustSDK.signPersonalMessage(message) { [weak self] signedMessage in
    // Use signedMessage
}

Example

Trust SDK includes an example project with the above code. To run the example project clone the repo and run pod install from the Example directory. Open TrustSDKExample.xcworkspace and run. Make sure that you have Trust Wallet installed on the device or simulator to test the full callback flow.

Authors

  • Viktor Radchenko
  • Alejandro Isaza

License

TrustSDK is available under the MIT license. See the LICENSE file for more info.

trustsdk-ios's People

Contributors

vikmeup avatar alejandro-isaza avatar hewigovens avatar artemgoryunov avatar hskang9 avatar

Watchers

Richard Burton avatar James Cloos 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.