TezosKit 5.2.1

TezosKit 5.2.1

Keefer Taylor 维护。



 
依赖
BigInt~> 5.0.0
MnemonicKit~> 1.3.12
PromiseKit~> 6.13.1
Base58Swift~> 2.1.10
CryptoSwift~> 1.3.0
Sodium~> 0.8.0
secp256k1.swift~> 0.1.4
DTTJailbreakDetection~> 0.4.0
 

TezosKit 5.2.1

  • 作者:
  • Keefer Taylor

TezosKit

Build Status codecov Carthage Compatible Version License

TezosKit 是一个 swift SDK,兼容 Tezos 区块链。TezosKit 实现了与区块链的复杂交互,包括:

  • 对操作进行预应用程序
  • 根据需要自动揭示账户
  • 批量处理多个操作

TezosKit 提供了与 Tezos 节点Conseil(一种索引服务)交互的本地功能。TezosKit 通过基于闭包的回调和 Promise(PromiseKit)功能与链交互。

TezosKit 兼容 CocoaPods 和 Carthage。有关具体指令,请参阅下面的安装部分。

快速开始

钱包和账户

Tezos 中的账户由 Wallet 对象表示。

创建新钱包

let wallet = Wallet()!
print("The wallet's mnemonic is \(wallet.mnemonic)")

恢复钱包

let mnemonic = ...
let wallet = Wallet(mnemonic: mnemonic)!

与 Tezos 节点交互

TezosNodeClient 类支持与 Tezos 节点交互。交互可以通过闭包回调或 Promises 完成。

let tezosNodeClient = TezosClient()

// Closure completion handler
tezosNodeClient.getBalance(address: "KT1BVAXZQUc4BGo3WTJ7UML6diVaEbe4bLZA") { result in
  switch result {
  case .success(let balance):
    print("The balance of the contract is \(balance.humanReadableRepresentation)")
  case .failure(let error):
    print("Error getting balance: \(error)")
  }
}

// PromiseKit Promises
tezosNodeClient.getBalance(address: "KT1BVAXZQUc4BGo3WTJ7UML6diVaEbe4bLZA").done { balance in
  print("The balance of the contract is \(balance.humanReadableRepresentation)")
} .catch { _ in
  print("Couldn't get balance.")
}

有关更多交互 Tezos 节点的信息,请参阅 Tezos 节点文档

与Conseil交互

ConseilClient类支持与Conseil服务的交互。交互可以通过闭包回调或Promise来完成。

let conseilClent = ConseilClient(...)
let address = "tz1iZEKy4LaAjnTmn2RuGDf2iqdAQKnRi8kY"

// Closure completion handler
conseilClient.originatedAccounts(from: address) { result in
  switch result {
    case .success(let originatedAccounts):
      print("Originated Accounts:")
      print(result)
    case .failure(let error):
      print("Error fetching originated accounts: \(error)")
  }
}

// PromiseKit Promises
conseilClient.originatedAccounts(from: address).done { result in
  print("Originated Accounts:")
  print(result)
} .catch { error in
  print("Error fetching originated accounts: \(error)")
}

更多关于与Conseil服务交互的内容,请参阅Conseil文档

高级使用方法

TezosKit高度可扩展,以满足任何项目的需求。项目可以自定义发送到节点的RPC和操作。有关自定义TezosKit行为的更多信息,请参阅高级使用文档

安装

您可以使用Carthage或CocoaPods来依赖TezosKit。

CocoaPods

TezosKit支持通过CocoaPods进行安装。您可以在Podfile中添加以下内容来依赖TezosKit:

pod "TezosKit"

Carthage

如果您使用Carthage管理依赖项,只需将TezosKit添加到您的Cartfile中。

github "keefertaylor/TezosKit"

如果您使用Carthage构建依赖项,请确保您已将这些框架添加到目标的"链接框架和库"部分:Base58Swift.frameworkBigInt.frameworkMnemonicKit.frameworkPromiseKit.frameworkSodium.frameworkTezosCrypto.framework,并将其包含在您的Carthage框架复制构建阶段。

错误 / 贡献

如果在TezosKit中发现错误或缺少功能,请随意在GitHub上创建一个问题。您可能需要检查您所建议的工作是否在未来工作中计划。

欢迎提交贡献和错误修复。如果您能提供对任何缺失或错误的功能的修复,请为这些功能打开一个PR(Pull Request)。

入门指南:设置

$ brew install xcodegen # if you don't already have it
$ xcodegen generate # Generate an XCode project from project.yml
$ open TezosKit.xcodeproj

许可证

TezosKit采用宽松的MIT许可证。

参见