All Projects → consenlabs → Token Core Android

consenlabs / Token Core Android

Licence: apache-2.0
a blockchain private key management library on android

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Token Core Android

Blockchainwallet Crypto
比特币、以太坊公私钥生成以及签名,长时间不维护可移步 https://github.com/QuincySx/ChainWallet
Stars: ✭ 183 (-70.15%)
Mutual labels:  blockchain, ethereum, bitcoin, eos
Token Core Ios
a blockchain private key management library on iOS
Stars: ✭ 850 (+38.66%)
Mutual labels:  blockchain, ethereum, bitcoin, eos
Awesome Blockchain
区块链白皮书、书籍、交易所、币种、自媒体等资源汇总 💯
Stars: ✭ 747 (+21.86%)
Mutual labels:  blockchain, ethereum, bitcoin, eos
Blockchain
区块链、交易所、币种、自媒体、高频交易策略
Stars: ✭ 37 (-93.96%)
Mutual labels:  blockchain, ethereum, bitcoin, eos
Awesome Blockchain
⚡️Curated list of resources for the development and applications of blockchain.
Stars: ✭ 937 (+52.85%)
Mutual labels:  blockchain, ethereum, bitcoin, eos
Blockchainage
「区块链技术指北」相关资料。
Stars: ✭ 51 (-91.68%)
Mutual labels:  blockchain, ethereum, bitcoin, eos
Introducing Ethereum And Solidity
Programming examples from the book.
Stars: ✭ 221 (-63.95%)
Mutual labels:  blockchain, ethereum, bitcoin
Merkletreejs
🌱 Construct Merkle Trees and verify proofs in JavaScript.
Stars: ✭ 238 (-61.17%)
Mutual labels:  blockchain, ethereum, bitcoin
Time Series Machine Learning
Machine learning models for time series analysis
Stars: ✭ 261 (-57.42%)
Mutual labels:  blockchain, ethereum, bitcoin
Squeezer
Squeezer Framework - Build serverless dApps
Stars: ✭ 3,242 (+428.87%)
Mutual labels:  blockchain, ethereum, bitcoin
Cointop
A fast and lightweight interactive terminal based UI application for tracking cryptocurrencies 🚀
Stars: ✭ 2,912 (+375.04%)
Mutual labels:  blockchain, ethereum, bitcoin
Octopus
Security Analysis tool for WebAssembly module (wasm) and Blockchain Smart Contracts (BTC/ETH/NEO/EOS)
Stars: ✭ 261 (-57.42%)
Mutual labels:  blockchain, ethereum, eos
Simcoin
Blockchain simulation framework with Docker and Python.
Stars: ✭ 470 (-23.33%)
Mutual labels:  blockchain, ethereum, bitcoin
Blockchain Stuff
Blockchain and Crytocurrency Resources
Stars: ✭ 2,549 (+315.82%)
Mutual labels:  blockchain, ethereum, bitcoin
Exchangesharp
ExchangeSharp is a powerful, fast and easy to use .NET/C# API for interfacing with many crypto currency exchanges. REST and web sockets are supported.
Stars: ✭ 489 (-20.23%)
Mutual labels:  blockchain, ethereum, bitcoin
Unstoppable Wallet Ios
A secure and decentralized Bitcoin and other cryptocurrency wallet for iPhone. Supports Bitcoin, Ethereum, EOS, Binance Chain, Bitcoin Cash, DASH, ...
Stars: ✭ 180 (-70.64%)
Mutual labels:  blockchain, ethereum, bitcoin
Cryptolist
Curated collection of blockchain & cryptocurrency resources.
Stars: ✭ 3,501 (+471.13%)
Mutual labels:  blockchain, ethereum, bitcoin
Ethereumkit
EthereumKit is a free, open-source Swift framework for easily interacting with the Ethereum.
Stars: ✭ 400 (-34.75%)
Mutual labels:  blockchain, ethereum, bitcoin
Unchained
My personal study of blockchain related technology.
Stars: ✭ 379 (-38.17%)
Mutual labels:  blockchain, ethereum, bitcoin
Awesome Blockchain Articles
A collection of awesome blockchain articles. Good learning resources about blockchain.
Stars: ✭ 552 (-9.95%)
Mutual labels:  blockchain, ethereum, bitcoin

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 addition, TokenCore introduces the concept of 'identity', you can use the same mnemonic to manage wallets on the three chains.

Installation

Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency

dependencies {
	implementation 'com.github.consenlabs:token-core-android:v0.1'
}

Step 3. Add the JAVA8 support to your build.gradle

android {
    ……
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
   ……
}

Step 4. (Optional) When you wants to debug your app in Android Oreo you shoud add the blow code to your build.gradle. Pls ref to https://issuetracker.google.com/issues/65941637 for more info.

android {
    ……
    packagingOptions {
        exclude 'lib/x86_64/darwin/libscrypt.dylib'
    }
   ……
}

Try the API

Init the storage to store the keystore file

public class MainActivity extends AppCompatActivity implements KeystoreStorage {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        WalletManager.storage = this;
        WalletManager.scanWallets();
    }

    public File getKeystoreDir() {
        return this.getFilesDir();
    }
}

Create new Identity and derive the eth, btc wallets

// You should create or recover Identity first before you create other wallets
// The last param, Metadata.P2WPKH means that the derived btc wallet is a SegWit wallet
Identity identity = Identity.createIdentity("MyFirstIdentity", SampleKey.PASSWORD, SampleKey.PASSWORD_HINT, Network.MAINNET, Metadata.P2WPKH);


Wallet ethereumWallet = identity.getWallets().get(0);
Wallet bitcoinWallet = identity.getWallets().get(1);

Export Wallet

String prvKey = WalletManager.exportPrivateKey(ethereumWallet.getId(), SampleKey.PASSWORD);
System.out.println(String.format("PrivateKey: %s", prvKey));
String mnemonic = WalletManager.exportMnemonic(ethereumWallet.getId(), SampleKey.PASSWORD).getMnemonic();
System.out.println(String.format("Mnemonic: %s", mnemonic));
String json = WalletManager.exportKeystore(ethereumWallet.getId(), SampleKey.PASSWORD);
System.out.println(String.format("Keystore: %s", json));

// 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

EthereumTransaction tran = new EthereumTransaction(BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String data)
TxSignResult result = tran.signTransaction(chainId, SampleKey.PASSWORD, ethereumWallet);
String signedTx = result.getSignedTx(); // This is the signature result which you need to broadcast.
String txHash = result.getTxHash(); // This is txHash which you can use for locating your transaction record

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].