• This repository has been archived on 20/May/2021
  • Stars
    star
    102
  • Rank 335,584 (Top 7 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 5 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

WalletConnect Swift client SDK

WalletConnect

Codacy Badge CI

WalletConnect Swift SDK, implements 1.0.0 websocket based protocol.

Demo video

Requirements

  • iOS 11
  • Xcode 10.2
  • Swift 5

Features

  • Connect and disconnect
  • Approve / Reject / Kill session
  • Approve and reject eth_sign / personal_sign / eth_signTypedData
  • Approve and reject eth_signTransaction / eth_sendTransaction
  • Approve and reject bnb_sign (binance dex orders)
  • session persistent / recovery

Todo:

  • push notification (APNS)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

WalletConnect is available through CocoaPods, Carthage and Swift Package Manager.

CocoaPods

To install it, simply add the following line to your Podfile:

pod 'WalletConnect', git: 'https://github.com/trustwallet/wallet-connect-swift', branch: 'master'

Carthage

Add following line to your Cartfile:

github "trustwallet/wallet-connect-swift"

Swift Package Manager

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

dependencies: [
    .package(url: "https://github.com/trustwallet/wallet-connect-swift", .branch("master")),
],

Usage

parse session from scanned QR code:

let string = "wc:..."
guard let session = WCSession.from(string: string) else {
    // invalid session
    return
}
// handle session

configure and handle incoming message:

let interactor = WCInteractor(session: session, meta: clientMeta)
interactor.onSessionRequest = { [weak self] (id, peer) in
    // ask for user consent
}

interactor.onDisconnect = { [weak self] (error) in
    // handle disconnect
}

interactor.eth.onSign = { [weak self] (id, payload) in
    // handle eth_sign, personal_sign, eth_signTypedData
}

interactor.eth.onTransaction = { [weak self] (id, event, transaction) in
    // handle eth_signTransaction / eth_sendTransaction
}

interactor.bnb.onSign = { [weak self] (id, order) in
    // handle bnb_sign
}

approve session

interactor.approveSession(accounts: accounts, chainId: chainId).done {
    print("<== approveSession done")
}.cauterize()

approve request

interactor.approveRequest(id: id, result: result.hexString).done {
    print("<== approveRequest done")
}.cauterize()

approve binance dex orders

interactor?.approveBnbOrder(id: id, signed: signed).done({ confirm in
    print("<== approveBnbOrder", confirm)
}).cauterize()

Author

hewigovens

License

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

More Repositories

1

assets

A comprehensive, up-to-date collection of information about several thousands (!) of crypto tokens.
Go
4,539
star
2

wallet-core

Cross-platform, cross-blockchain wallet library.
C++
2,767
star
3

trust-wallet-ios

πŸ“± Trust - Ethereum Wallet and Web3 DApp Browser for iOS
Swift
1,520
star
4

trust-web3-provider

Web3 javascript wrapper provider for iOS and Android platforms.
TypeScript
747
star
5

trust-wallet-android-source

Trust - Ethereum Wallet for Android (Inactive Repository)
Java
385
star
6

blockatlas

Clean and lightweight cross-chain transaction API
Go
368
star
7

tokens

Upload yours token, coin and dApp image to get displayed in the Trust Wallet
JavaScript
345
star
8

developer

Trust Developer documentation: developer.trustwallet.com
337
star
9

TrustSDK-iOS

No longer maintained. https://community.trustwallet.com/t/trustsdk-is-discontinued/213116
Swift
226
star
10

trust-ray

☁️ API for the Trust Wallet. Project no longer supported and current version used as source of transactions and address tokens in Blockatlas https://github.com/trustwallet/blockatlas/blob/master/config.yml#L64
TypeScript
185
star
11

TrustSDK-Android

No longer maintained. https://community.trustwallet.com/t/trustsdk-is-discontinued/213116
Kotlin
152
star
12

dapps-browser

DApps browser
JavaScript
131
star
13

trust-keystore

A general-purpose Ethereum keystore for managing wallets.
Swift
119
star
14

go-libs

Go
91
star
15

wallet-connect-kotlin

Kotlin
90
star
16

watchmarket

Watchmarket is an aggregation and caching service for blockchain market information
Go
86
star
17

trustsdk-react-native

No longer maintained. https://community.trustwallet.com/t/trustsdk-is-discontinued/213116
TypeScript
82
star
18

trust-core

DEPRECATED. Please use wallet-core
Swift
70
star
19

go-primitives

Go
59
star
20

Web3View

Java
52
star
21

trust-api

TypeScript
30
star
22

barz

A Secure, Modular, Upgradeable Smart Contract Wallet enabling mass adoption of Web3
TypeScript
28
star
23

ens-coincodec

Go
25
star
24

wizard-sdk

Wizard-SDK, a TypeScript software development kit, is designed to visualize diverse protocol EIP-712 messages and simulate transactions that users sign daily in the web3.0 environment.
TypeScript
25
star
25

ansible-collection-blockchain

Trust Wallet's Ansible Galaxy Collection of roles to configure blockchain nodes.
Jinja
23
star
26

web-core

TypeScript
16
star
27

dokka

WalletCore Kotlin API documentation
Shell
13
star
28

assets-go-libs

Go
12
star
29

web3-react-trust-wallet

TypeScript
10
star
30

trezor-crypto-ios

πŸ“™ Heavily optimized cryptography algorithms for embedded devices, packaged for iOS.
Ruby
9
star
31

docc

WalletCore Swift API documentation
Shell
2
star
32

multiversx

MultiversX metadata
2
star
33

solana-wallet-standard

2
star