token-core-ios a blockchain private key management

我要开发同款
匿名用户2021年11月30日
71阅读
所属分类、Web3、区块链
授权协议Apache-2.0 License

作品详情

TokenCore

TokenCoreisablockchainlibrary.TokenCoreprovidestherelativelyconsistentAPIthatallowsyoutomanageyourwalletsandsigntransactionsinBTC,ETHandEOSchainssimultaneously.Inaddition,TokenCoreintroducestheconceptof'identity',youcanusethesamemnemonictomanagewalletsonthethreechains.

Installation

ToinstallTokenCore,useCocoaPodsandaddthistoyourPodfile:

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

Theexampleshowhowtomanagerthewalletandsigntransaction,theeossignwillcomingsoon.

$cdExample$podinstallTrytheAPICreatenewIdentityandderivetheeth,btcwallets//YoushouldcreateorrecoverIdentityfirstbeforeyoucreateotherwalletsdo{varmetadata=WalletMeta(source:.newIdentity)metadata.network=Network.mainnetmetadata.segWit=.p2wpkh//.p2wpkhmeansthatthederivedbtcwalletisaSegWitwalletmetadata.name="MyFirstIdentity"let(mnemonic,identity)=tryIdentity.createIdentity(password:TestData.password,metadata:metadata)letethereumWallet=identity.wallets[0]letbitcoinWalelt=identity.wallets[1]}catch{print("createIdentityfailed,error:\(error)")}ExportWalletletprvKey=tryWalletManager.exportPrivateKey(walletID:ethereumWallet.walletID,password:TestData.password)print("PrivateKey:\(prvKey)")letmnemonics=tryWalletManager.exportMnemonic(walletID:ethereumWallet.walletID,password:TestData.password)print("Mnemonic:\(mnemonics)")letkeystore=tryWalletManager.exportKeystore(walletID:ethereumWallet.walletID,password:TestData.password)print("Keystore:\(keystore)")//output://PrivateKey:f653be3f639f45ea1ed3eb152829b6d881ce62257aa873891e06fa9569a8d9aa//Mnemonic:tideinmatecloudaroundwisebargaincelerycementjunglemelodygalaxygrocery//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"}SignTransactionletsignResult=WalletManager.ethSignTransaction(walletID:String,nonce:String,gasPrice:String,gasLimit:String,to:String,value:String,data:String,password:String,chainID:Int)letsignedTx=signResult.signedTx//Thisisthesignatureresultwhichyouneedtobroadcast.lettxHahs=signResult.txHash//ThisistxHashwhichyoucanuseforlocatingyourtransactionrecordTroubleshooting

FormacOS10.14MojaveandXcode10,install/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkgsinceXcodecommandlinetoolsdon'tinstallto/usr/includeanymore.

TODOTestonObjective-CupgradetheBigIntfrom3.0to3.1CopyrightandLicenseCopyright2018imTokenPTE.LTD.LicensedundertheApacheLicense,Version2.0(the"License");youmaynotusethisfileexceptincompliancewiththeLicense.YoumayobtainacopyoftheLicenseathttps://www.apache.org/licenses/LICENSE-2.0Unlessrequiredbyapplicablelaworagreedtoinwriting,softwaredistributedundertheLicenseisdistributedonan"ASIS"BASIS,WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.SeetheLicenseforthespecificlanguagegoverningpermissionsandlimitationsundertheLicense.Thanksandmoreinfo

Thanksbitcoinj,CoreBitcoinandotherslibrary.

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论