{"id":23789762,"url":"https://github.com/consenlabs/token-core-android","last_synced_at":"2025-04-04T07:09:32.941Z","repository":{"id":54637695,"uuid":"154246246","full_name":"consenlabs/token-core-android","owner":"consenlabs","description":"a blockchain private key management library on android","archived":false,"fork":false,"pushed_at":"2023-11-21T06:03:11.000Z","size":194,"stargazers_count":652,"open_issues_count":17,"forks_count":199,"subscribers_count":41,"default_branch":"master","last_synced_at":"2025-03-28T06:09:55.758Z","etag":null,"topics":["bitcoin","blockchain","eos","ethereum"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/consenlabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-23T02:04:42.000Z","updated_at":"2025-02-28T01:52:34.000Z","dependencies_parsed_at":"2025-01-15T19:14:06.056Z","dependency_job_id":"ff404020-6dd5-42c1-8a36-c61ebc266c67","html_url":"https://github.com/consenlabs/token-core-android","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consenlabs%2Ftoken-core-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consenlabs%2Ftoken-core-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consenlabs%2Ftoken-core-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consenlabs%2Ftoken-core-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/consenlabs","download_url":"https://codeload.github.com/consenlabs/token-core-android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247135147,"owners_count":20889421,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitcoin","blockchain","eos","ethereum"],"created_at":"2025-01-01T17:16:06.262Z","updated_at":"2025-04-04T07:09:32.910Z","avatar_url":"https://github.com/consenlabs.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![](https://jitpack.io/v/consenlabs/token-core-android.svg)](https://jitpack.io/#consenlabs/token-core-android)\n\n\n## Token Core\nTokenCore 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.\nIn addition, TokenCore introduces the concept of 'identity', you can use the same mnemonic to manage wallets on the three chains.\n\n## Installation\n\nStep 1. Add the JitPack repository to your build file\nAdd it in your root build.gradle at the end of repositories:\n```groovy\n\tallprojects {\n\t\trepositories {\n\t\t\t...\n\t\t\tmaven { url 'https://jitpack.io' }\n\t\t}\n\t}\n```\n\nStep 2. Add the dependency\n```\ndependencies {\n\timplementation 'com.github.consenlabs:token-core-android:v0.1'\n}\n```\n\nStep 3. Add the JAVA8 support to your build.gradle\n```\nandroid {\n    ……\n    compileOptions {\n        sourceCompatibility JavaVersion.VERSION_1_8\n        targetCompatibility JavaVersion.VERSION_1_8\n    }\n   ……\n}\n```\n\nStep 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.\n```\nandroid {\n    ……\n    packagingOptions {\n        exclude 'lib/x86_64/darwin/libscrypt.dylib'\n    }\n   ……\n}\n```\n## Try the API\n### Init the storage to store the keystore file\n```\npublic class MainActivity extends AppCompatActivity implements KeystoreStorage {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        WalletManager.storage = this;\n        WalletManager.scanWallets();\n    }\n\n    public File getKeystoreDir() {\n        return this.getFilesDir();\n    }\n}\n```\n\n### Create new Identity and derive the eth, btc wallets\n```java\n// You should create or recover Identity first before you create other wallets\n// The last param, Metadata.P2WPKH means that the derived btc wallet is a SegWit wallet\nIdentity identity = Identity.createIdentity(\"MyFirstIdentity\", SampleKey.PASSWORD, SampleKey.PASSWORD_HINT, Network.MAINNET, Metadata.P2WPKH);\n\n\nWallet ethereumWallet = identity.getWallets().get(0);\nWallet bitcoinWallet = identity.getWallets().get(1);\n```\n### Export Wallet\n```java\n\nString prvKey = WalletManager.exportPrivateKey(ethereumWallet.getId(), SampleKey.PASSWORD);\nSystem.out.println(String.format(\"PrivateKey: %s\", prvKey));\nString mnemonic = WalletManager.exportMnemonic(ethereumWallet.getId(), SampleKey.PASSWORD).getMnemonic();\nSystem.out.println(String.format(\"Mnemonic: %s\", mnemonic));\nString json = WalletManager.exportKeystore(ethereumWallet.getId(), SampleKey.PASSWORD);\nSystem.out.println(String.format(\"Keystore: %s\", json));\n\n// output:\n// PrivateKey: f653be3f639f45ea1ed3eb152829b6d881ce62257aa873891e06fa9569a8d9aa\n// Mnemonic: tide inmate cloud around wise bargain celery cement jungle melody galaxy grocery\n// 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\"}\n```\n\n### SignTransaction\n```java\nEthereumTransaction tran = new EthereumTransaction(BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String data)\nTxSignResult result = tran.signTransaction(chainId, SampleKey.PASSWORD, ethereumWallet);\nString signedTx = result.getSignedTx(); // This is the signature result which you need to broadcast.\nString txHash = result.getTxHash(); // This is txHash which you can use for locating your transaction record\n```\n\n## Copyright and License\n\n```\n  Copyright 2018 imToken PTE. LTD.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n```\n\n## Thanks and more info\nThanks bitcoinj, CoreBitcoin and others library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconsenlabs%2Ftoken-core-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconsenlabs%2Ftoken-core-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconsenlabs%2Ftoken-core-android/lists"}