当前位置: 首页 > 软件库 > Web3 > 区块链 >

token-core-ios

a blockchain private key management library on iOS
授权协议 Apache-2.0 License
开发语言
所属分类 Web3、 区块链
软件类型 开源软件
地区 不详
投 递 者 徐嘉勋
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

TokenCore

TokenCore is a blockchain library. TokenCore provides the relatively consistent API that allows you to manage your wallets and sign transactions in BTC, ETH and EOS chains simultaneously.In addition, TokenCore introduces the concept of 'identity', you can use the same mnemonic to manage wallets on the three chains.

Installation

To install TokenCore, use CocoaPods and add this to your Podfile:

pod "TokenCore", git: "https://github.com/consenlabs/token-core-ios.git", branch: "master"

Run the Example

The example show how to manager the wallet and sign transaction, the eos sign will coming soon.

$ cd Example
$ pod install

Try the API

Create new Identity and derive the eth, btc wallets

// You should create or recover Identity first before you create other wallets
do {
  var metadata = WalletMeta(source: .newIdentity)
  metadata.network = Network.mainnet
  metadata.segWit = .p2wpkh // .p2wpkh means that the derived btc wallet is a SegWit wallet
  metadata.name = "MyFirstIdentity"
  let (mnemonic, identity) = try Identity.createIdentity(password: TestData.password, metadata: metadata)
  let ethereumWallet = identity.wallets[0]
  let bitcoinWalelt = identity.wallets[1]
} catch {
  print("createIdentity failed, error:\(error)")
}

Export Wallet

let prvKey = try WalletManager.exportPrivateKey(walletID: ethereumWallet.walletID, password: TestData.password)
print("PrivateKey: \(prvKey)")
let mnemonics = try WalletManager.exportMnemonic(walletID: ethereumWallet.walletID, password: TestData.password)
print("Mnemonic: \(mnemonics)")
let keystore = try WalletManager.exportKeystore(walletID: ethereumWallet.walletID, password: TestData.password)
print("Keystore: \(keystore)")

// output:
// PrivateKey: f653be3f639f45ea1ed3eb152829b6d881ce62257aa873891e06fa9569a8d9aa
// Mnemonic: tide inmate cloud around wise bargain celery cement jungle melody galaxy grocery
// Keystore: {"id":"c7575eba-3ae3-4cc3-86ba-2eb9c6839cad","version":3,"crypto":{"ciphertext":"7083ba3dd5470ba4be4237604625e05fa6b668954d270beb848365cbf6933ec5","mac":"f4f9ea8d42ff348b11fc146c396da446cc975309b3538e08a58c0b218bddd15d","cipher":"aes-128-ctr","cipherparams":{"iv":"db3f523faf4da4f1c6edcd7bc1386879"},"kdf":"pbkdf2","kdfparams":{"dklen":32,"c":10240,"prf":"hmac-sha256","salt":"0ce830e9f888dfe33c31e6cfc444d6f588161c9d4128d4066ee5dfdcbc5d0079"}},"address":"4a1c2072ac67b616e5c578fd9e2a4d30e0158471"}

SignTransaction

let signResult = WalletManager.ethSignTransaction(
        walletID: String,
        nonce: String,
        gasPrice: String,
        gasLimit: String,
        to: String,
        value: String,
        data: String,
        password: String,
        chainID: Int
      )
let signedTx = signResult.signedTx // This is the signature result which you need to broadcast.
let txHahs = signResult.txHash // This is txHash which you can use for locating your transaction record

Troubleshooting

For macOS 10.14 Mojave and Xcode 10, install /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg since Xcode command line tools don't install to /usr/include anymore.

TODO

  • Test on Objective-C
  • upgrade the BigInt from 3.0 to 3.1

Copyright and License

  Copyright 2018 imToken PTE. LTD.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

Thanks and more info

Thanks bitcoinj, CoreBitcoin and others library.

  • 需要在一个vue-iview项目中引入一个轻量级富文本,并且结合iview的upload钩子函数实现自定义图片上传token验证 思路: 将图片先上传至服务器,再将图片链接插入到富文本中 图片上传的话可以使用element或者iview,这里我以iview举例 图片上传区域要隐藏,自定义vue-quill-editor的图片上传,点击图片上传时调用iview或者element的图片上传, 上传成功

  • 唐巧的一篇面试总结 设计模式是什么? 你知道哪些设计模式,并简要叙述? 设计模式是一种编码经验,就是用比较成熟的逻辑去处理某一种类型的事情。 1). MVC模式:Model View Control,把模型 视图 控制器 层进行解耦合编写。 2). MVVM模式:Model View ViewModel 把模型 视图 业务逻辑 层进行解耦和编写。 3). 单例模式:通过static关键词,声明全局

  • 推送作为一个产品必备功能,越来越得到所有人的重用,市面上做推送的第三方公司也有很多,像个推,百度,甚至友盟也出了推送功能。用什么不是我们能决定的,而是上级或产品决定的,所以我负责的项目用了极光推送,我便来整理一下使用过程和踩了的坑。 开整 准备工作 苹果开发者账号,agent权限,即可以创建和管理证书的权限。 极光开发者账号。 待集成的app项目。 集成前的相关操作 推送证书创建 由于极光后台在创

 相关资料
  • Token Core TokenCore is a blockchain library. TokenCore provides the relatively consistent API that allows you to manage your wallets and sign transactions in BTC, ETH and EOS chains simultaneously.In

  • 令牌表示文档中的文本或单词,其中包含相关详细信息,如元数据(位置,起始偏移,结束偏移,标记类型及其位置增量)。 Class 声明 (Class Declaration) 以下是org.apache.lucene.analysis.Token类的声明: public class Token extends TermAttributeImpl implements TypeAttri

  • import "go/token" Package token defines constants representing the lexical tokens of the Go programming language and basic operations on tokens (printing, predicates). Index Constants type File func (

  • 定义用于与标准兼容的令牌消息和数据库表进行交互的ABI. 类 struct eosio::price 定义两个令牌之间的固定精确价格 struct eosio::token 详细描述

  • 刷新令牌是可用于获取新访问令牌的凭据。 与访问令牌的生命周期相比,刷新令牌的生命周期要长得多。 刷新令牌也可以过期,但是很长时间都很安静。 当前访问令牌过期或变为无效时,授权服务器向客户端提供刷新令牌以获取新的访问令牌。 下图说明了刷新过期的访问令牌的过程。 Step 1 - 首先,客户端通过授权授权向授权服务器进行身份验证。 Step 2 - 接下来,授权服务器验证客户端,验证授权授权并向客户端

  • 我们一个 SDK 应用在初始化以后,你可以在任何时机从应用中拿到该配置下的 Access Token 实例: use EasyWeChat\Factory; $config = [ //... ]; $app = Factory::officialAccount($config); // 获取 access token 实例 $accessToken = $app->access_t