Code Monkey home page Code Monkey logo

walletlink-mobile-sdk's Introduction

WalletLink Mobile Wallet SDK

WalletLink is an open protocol that lets users connect their mobile wallets to your DApp. For more details checkout https://github.com/CoinbaseWallet/walletlink

With the WalletLink SDK, your mobile wallet will be able to interact with DApps on the desktop and be able to sign web3 transactions and messages.

Use WalletLink mobile wallet SDK to support WalletLink in your mobile wallet.

iOS

Installation

# add WalletLink as a CocoaPod
pod 'CBWalletLink', git: '[email protected]:CoinbaseWallet/walletlink-mobile.git', commit: "89008b18f23f0fcfddfb00069385f06da77fbc58"

Usage

// Create an instance of WalletLink class
let walletLink = WalletLink(notificationUrl: notificationUrl)

// To pair the device with a browser after scanning WalletLink QR code
walletLink.link(
    sessionId: sessionId,
    secret: secret,
    url: serverUrl,
    userId: userId,
    metadata: [.ethereumAddress: ethereumAddress]
)
.subscribe(onSuccess: { _ in
    // New WalletLink connection was established
}, onError: { error in
    // Error while connecting to WalletLink server (walletlinkd)
})
.disposed(by: disposeBag)

// Listen on incoming requests
walletLink.requests
    .observeOn(MainScheduler.instance)
    .subscribe(onNext: { request in
        // New unseen request
    })
    .disposed(by: disposeBag)

// Approve DApp permission request (EIP-1102)
walletLink.approveDappPermission(requestId: request.hostRequestId)
    .subscribe(onSuccess: { _ in
        // Browser received EIP-1102 approval
    }, onError: { error in
        // Browser failed to receive EIP-1102 approval
    })
    .disposed(by: disposeBag)

// Approve a given transaction/message signing request
walletLink.approve(requestId: request.hostRequestId, signedData: signedData)
    .subscribe(onSuccess: { _ in
        // Browser received request approval
    }, onError: { error in
        // Browser failed to receive request approval
    })
    .disposed(by: disposeBag)

// Reject transaction/message/EIP-1102 request
walletLink.reject(requestId: request.hostRequestId)
    .subscribe(onSuccess: { _ in
        // Browser received request rejection
    }, onError: { error in
        // Browser failed to receive request rejection
    })
    .disposed(by: disposeBag)

Android

Installation

# add WalletLink as a submodule
$ git submodule add [email protected]:CoinbaseWallet/walletlink-mobile.git

Usage

// Create an instance of WalletLink class
val walletLink = WalletLink(notificationUrl, context)

// To pair the device with a browser after scanning WalletLink QR code
walletLink.link(
    sessionId = sessionId,
    secret = secret,
    url = serverUrl,
    userId = userId,
    metadata = mapOf(ClientMetadataKey.EthereumAddress to wallet.primaryAddress)
)
.subscribeBy(onSuccess = {
    // New WalletLink connection was established
}, onError = { error ->
    // Error while connecting to WalletLink server (walletlinkd)
})
.addTo(disposeBag)

// Listen on incoming requests
walletLink.requests
    .observeOn(AndroidSchedulers.mainThread())
    .subscribeBy(onNext = { request ->
        // New unseen request
    })
    .addTo(disposeBag)

// Approve DApp permission request (EIP-1102)
walletLink.approveDappPermission(request.hostRequestId)
    .subscribeBy(onSuccess = {
        // Browser received EIP-1102 approval
    }, onError = { error ->
        // Browser failed to receive EIP-1102 approval
    })
    .addTo(disposeBag)

// Approve a given transaction/message signing request
walletLink.approve(request.hostRequestId, signedData)
    .subscribeBy(onSuccess = {
        // Browser received request approval
    }, onError = { error ->
        // Browser failed to receive request approval
    })
    .addTo(disposeBag)

// Reject transaction/message/EIP-1102 request
walletLink.reject(request.hostRequestId)
    .subscribeBy(onSuccess = {
        // Browser received request rejection
    }, onError = { error ->
        // Browser failed to receive request rejection
    })
    .addTo(disposeBag)

walletlink-mobile-sdk's People

Contributors

andrewgold avatar hieronymus777 avatar hishbase avatar johnnycoinbase 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.