WalletConnect Swift SDK v2

Overview

Wallet Connect v.2 - Swift

Swift implementation of WalletConnect v.2 protocol for native iOS applications.

Requirements

  • iOS 13
  • XCode 13
  • Swift 5

Usage

Responder

Responder client is usually a wallet.

Instantiate Client
let url = URL(string: "wss://relay.walletconnect.org")!
let options = WalletClientOptions(apiKey: String, name: String, isController: true, metadata: AppMetadata(name: String?, description: String?, url: String?, icons: [String]?), relayURL: url)
let client = WalletConnectClient(options: options)

The controller client will always be the "wallet" which is exposing blockchain accounts to a "dapp" and therefore is also in charge of signing.

After instantiation of a client set its delegate.

Pair Clients

Pair client with a uri generated by the proposer client.

let uri = "wc:..."
try! client.pair(uri: uri)

Approve Session

Sessions are always proposed by the Proposer client so Responder client needs either reject or approve a session proposal.

class ClientDelegate: WalletConnectClientDelegate {
...
    func didReceive(sessionProposal: SessionType.Proposal) {
        client.approve(proposal: proposal, accounts: [String])
    }
...

or

    func didReceive(sessionProposal: SessionType.Proposal) {
        client.reject(proposal: proposal, reason: Reason)
    }

NOTE: addresses provided in accounts array should follow CAPI10 semantics.

Handle Delegate methods

    func didSettle(session: SessionType.Settled) {
        // handle settled session
    }
    func didReceive(sessionProposal: SessionType.Proposal) {
        // handle session proposal
    }
    func didReceive(sessionRequest: SessionRequest) {
        // handle session request
    }

JSON-RPC Payloads

Receive

You can parse JSON-RPC Requests received from "Requester" in didReceive(sessionRequest: SessionRequest) delegate function.

Request parameters can be type casted based on request method as below:

            let params = try! sessionRequest.request.params.get([EthSendTransaction].self)
Respond
            let jsonrpcResponse = JSONRPCResponse<AnyCodable>(id: request.id, result: AnyCodable(responseParams))
            client.respond(topic: sessionRequest.topic, response: jsonrpcResponse)

Installation

Swift Package Manager

Add .package(url:_:) to your Package.swift:

dependencies: [
    .package(url: "https://github.com/WalletConnect-Labs/WalletConnectSwiftV2", .branch("main")),
],

Example App

open Example/ExampleApp.xcodeproj

License

LGPL-3.0

You might also like...
A simple to use iOS/tvOS/watchOS SDK to help get you off the ground quickly and efficiently with your Elastic Path Commerce Cloud written in Swift.

Elastic Path Commerce Cloud iOS Swift SDK A simple to use iOS/tvOS/watchOS SDK to help get you off the ground quickly and efficiently with your Elasti

Sample project with local swift package linked NDI SDK.

NDISwiftPackage Sample project with local swift package linked NDI SDK. Preparation Install NDA SDK on your mac. Software Developer Kit Make package c

Stacksift App SDK

Stacksift SDK Capture and submit crashes to Stacksift. This library ties together Wells and Impact to provide a full crash capturing and submission sy

TelegramStickersImport — Telegram stickers importing SDK for iOS

TelegramStickersImport — Telegram stickers importing SDK for iOS TelegramStickersImport helps your users import third-party programaticaly created sti

Official Appwrite SDK for Apple Devices 🍎
Official Appwrite SDK for Apple Devices 🍎

Appwrite Apple SDK This SDK is compatible with Appwrite server version 0.11.x. For older versions, please check previous releases. Appwrite is an open

Muxer used on top of Feed iOS SDK for airplay

FeedAirplayMuxer Muxer used on top of Feed iOS SDK for airplay purposes. Demo Project -- https://github.com/feedfm/AirplayDemo Feed Airplay Muxer is

Basispay IOS SDK Version 2

BasisPay-IOS-KIT BasisPay IOS Payment Gateway kit for developers INTRODUCTION This document describes the steps for integrating Basispay online paymen

The Gini Bank SDK provides components for capturing, reviewing and analyzing photos of invoices and remittance slips.
The Gini Bank SDK provides components for capturing, reviewing and analyzing photos of invoices and remittance slips.

Gini Bank SDK for iOS The Gini Bank SDK provides components for capturing, reviewing and analyzing photos of invoices and remittance slips. By integra

Release repo for Gini Bank SDK for iOS
Release repo for Gini Bank SDK for iOS

Gini Bank SDK for iOS The Gini Bank SDK provides components for capturing, reviewing and analyzing photos of invoices and remittance slips. By integra

Owner
WalletConnect Labs
Developing software solutions for decentralized identity and digital wallet authentication
WalletConnect Labs
Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.

Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.

Alter 45 Nov 29, 2022
RadioTimeKit - The Swift SDK for TuneIn RadioTimeKit is a Swift package to use the TuneIn API.

RadioTimeKit - The Swift SDK for TuneIn RadioTimeKit is a Swift package to use the TuneIn API. The goal for development was to have a Swift SDK to get

Frank Gregor 2 Jun 20, 2022
This is swift project example to connect VNPTSmartCA SDK using Swift Language.

Example source code to integrate with VNPTSmartCA iOS SDK To run the example project, clone repository, and run pod install Requirements Installation

null 1 Feb 14, 2022
Home-assistant-swift-sdk - Used to integrate the Home Assistant APIs with your Swift-based apps.

home-assistant-swift-sdk This open-source library allows you to interact with a Home Assistant instance in your Swift-based (e.g., iOS, macOS, etc.) a

Alexander Golden 0 Dec 31, 2021
Official Appwrite Swift SDK 🦅🍎

Appwrite Swift SDK This SDK is compatible with Appwrite server version 0.11.x. For older versions, please check previous releases. This is the Swift S

Appwrite 27 Dec 25, 2022
Swift SDK for Blockfrost.io API

Swift5 API client for Blockfrost Swift 5 SDK for Blockfrost.io API. Installation • Usage • API Endpoints Installation Swift package manager dependenci

blockfrost.io 10 Dec 24, 2022
MpesaSDK - Swift SDK for the M-Pesa API (Mozambique)

M-Pesa SDK Swift package for M-Pesa API (Mozambique) Ready Methods/APIs C2B B2B

Algy Ali 16 Jul 29, 2022
MbientLab 2 Feb 5, 2022
Federal Data SDK built in the Swift programming language. Follow the link for the documentation:

Swift-Federal-Data-SDK Federal Data SDK built in the Swift programming language Until the Swift language becomes more stable, consider this a beta rel

null 65 May 28, 2022
Swift SDK for Apache Kafka

SwiftKafka A swift implementation of Kafka for producing and consuming from event streams. This works by wrapping the librdkafka C library. Swift vers

Kitura 55 Dec 27, 2022