添加依赖
WalletConnect Swift SDK, implements 1.0.0 websocket based protocol.
Demo video
eth_sign
personal_sign
eth_signTypedData
eth_signTransaction
eth_sendTransaction
bnb_sign
Todo:
To run the example project, clone the repo, and run pod install from the Example directory first.
pod install
WalletConnect is available through CocoaPods, Carthage and Swift Package Manager.
To install it, simply add the following line to your Podfile:
Podfile
pod 'WalletConnect', git: 'https://github.com/trustwallet/wallet-connect-swift', branch: 'master'
Add following line to your Cartfile:
Cartfile
github "trustwallet/wallet-connect-swift"
Add .package(url:_:) to your Package.swift:
.package(url:_:)
Package.swift
dependencies: [ .package(url: "https://github.com/trustwallet/wallet-connect-swift", .branch("master")), ],
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()
hewigovens
WalletConnect is available under the MIT license. See the LICENSE file for more info.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
WalletConnect
WalletConnect Swift SDK, implements 1.0.0 websocket based protocol.
Demo video
Requirements
Features
eth_sign
/personal_sign
/eth_signTypedData
eth_signTransaction
/eth_sendTransaction
bnb_sign
(binance dex orders)Todo:
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
:Carthage
Add following line to your
Cartfile
:Swift Package Manager
Add
.package(url:_:)
to yourPackage.swift
:Usage
parse session from scanned QR code:
configure and handle incoming message:
approve session
approve request
approve binance dex orders
Author
hewigovens
License
WalletConnect is available under the MIT license. See the LICENSE file for more info.