├── .gitignore ├── .idea ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── info │ │ └── bcdev │ │ └── easytoken │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── info │ │ │ └── bcdev │ │ │ └── easytoken │ │ │ ├── MainActivity.java │ │ │ ├── SaveWallet.java │ │ │ └── config.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ └── qr_view.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── info │ └── bcdev │ └── easytoken │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── librarysdkew ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── info │ │ └── bcdev │ │ └── librarysdkew │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── info │ │ │ └── bcdev │ │ │ └── librarysdkew │ │ │ ├── GetCredentials.java │ │ │ ├── interfaces │ │ │ └── callback │ │ │ │ ├── CBBip44.java │ │ │ │ ├── CBEtherScan.java │ │ │ │ ├── CBGetCredential.java │ │ │ │ ├── CBLoadSmartContract.java │ │ │ │ ├── CBSendingEther.java │ │ │ │ └── CBSendingToken.java │ │ │ ├── smartcontract │ │ │ ├── LoadSmartContract.java │ │ │ └── TokenERC20.java │ │ │ ├── utils │ │ │ ├── EtherScan.java │ │ │ ├── InfoDialog.java │ │ │ ├── ToastMsg.java │ │ │ ├── identicon │ │ │ │ ├── BlockiesData.java │ │ │ │ ├── BlockiesIdenticon.java │ │ │ │ └── Identicon.java │ │ │ └── qr │ │ │ │ ├── Generate.java │ │ │ │ └── ScanIntegrator.java │ │ │ ├── wallet │ │ │ ├── Balance.java │ │ │ ├── SendingEther.java │ │ │ ├── SendingToken.java │ │ │ └── generate │ │ │ │ ├── Bip44.java │ │ │ │ ├── Default.java │ │ │ │ └── crypto │ │ │ │ └── MnemonicUtils.java │ │ │ └── web3j │ │ │ └── Initiate.java │ └── res │ │ └── values │ │ ├── Identicon.xml │ │ └── strings.xml │ └── test │ └── java │ └── info │ └── bcdev │ └── librarysdkew │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | *.apk 4 | /local.properties 5 | /.idea/workspace.xml 6 | /.idea/libraries 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | app/src/main/java/ru/fastsrv/easytoken/config.java 12 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EasyToken/Android-Wallet-Token-ERC20/5eb1567afffdde1b99d51d401a0ba1fd571dcbf1/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 23 | 33 | 34 | 35 | 36 | 37 | 38 | 40 | 41 | 42 | 43 | 44 | 1.8 45 | 46 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android Wallet TokenERC20 2 | 3 | This gives a detailed description of working with [Web3j library](https://github.com/web3j/web3j) 4 | 5 | The basis of the library is its own SDK, which simplifies the production of applications for Android devices. 6 | 7 | Possibility of sdkew module: 8 | 9 | + Wallet Generation 10 | 1. Bip44 (Seed Code) 11 | 2. Default (Стандартным способом web3j) 12 | + ol Obtaining credential 13 | 1. From file wallet (Json) 14 | 2. Seed Phrase 15 | 3. Private Key 16 | + Sending 17 | 1. Ethers 18 | + Get Balance 19 | 1. in Wei 20 | 2. in Ether 21 | + QR 22 | 1. Scan (with Zxing) 23 | 2. Generation (with ZXing Android Embedded) 24 | + Indenticon 25 | + Work with the smart contract ERC20 26 | 1. get Name Token 27 | 2. get Symbol Token 28 | 3. get Supply Token 29 | 4. get Balance 30 | 5. and other 31 | + EtherScan 32 | 33 | ## Getting started 34 | 35 | Download or clone a project and open it in your Android Studio 36 | 37 | ## Help in developing 38 | 39 | I’m writing a description of how to work with the web3j library on [my blog](https://bcdev.info/en/) and [Wiki](https://github.com/EasyToken/Android-Wallet-Token-ERC20/wiki), there will also be a description of working with the module and with the Ethereum network. 40 | 41 | All questions and suggestions can be left in the [Telegram group](https://t.me/joinchat/D62dXAwO6kkm8hjlJTR9VA). 42 | 43 | ## Bugs 44 | 45 | I would be grateful for feedback on errors, shortcomings. 46 | + [Telegram group](https://t.me/joinchat/D62dXAwO6kkm8hjlJTR9VA) 47 | + [Issues](https://github.com/EasyToken/Android-Wallet-Token-ERC20/issues) 48 | 49 | ## Projects using this repo 50 | 51 | * [iWallet](https://play.google.com/store/apps/details?id=tech.insense.sensewalet) 52 | * [EthereumPaperWallet](https://play.google.com/store/apps/details?id=info.bcdev.ethereumpaperwallet) 53 | 54 | ## Contributing 55 | 56 | If you have ideas or interesting projects in which I can participate, do not hesitate to share them with me. 57 | 58 | ## Donations 59 | 60 | | ![Ethereum Address](https://bcdev.info/wp-content/uploads/2018/10/ethereum_logo.png) | ![Bitcoin Address](https://bcdev.info/wp-content/uploads/2018/10/bitcoin_logo.png) | 61 | | --- | --- | 62 | | ![QR Code Eth Address](https://bcdev.info/wp-content/uploads/2018/10/qr_code_eth_address.png) | ![QR Code Bitcoin Address](https://bcdev.info/wp-content/uploads/2018/10/qr_code_btc_address.png) | 63 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | defaultConfig { 6 | multiDexEnabled true 7 | applicationId 'info.bcdev.easytoken' 8 | minSdkVersion 16 9 | targetSdkVersion 26 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | productFlavors { 21 | } 22 | } 23 | 24 | dependencies { 25 | implementation fileTree(include: ['*.jar'], dir: 'libs') 26 | implementation 'com.android.support:appcompat-v7:27.1.1' 27 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 28 | testImplementation 'junit:junit:4.12' 29 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 30 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 31 | implementation 'org.web3j:core:3.3.1-android' 32 | implementation 'com.journeyapps:zxing-android-embedded:3.6.0' 33 | implementation 'com.googlecode.json-simple:json-simple:1.1' 34 | implementation 'com.google.zxing:core:3.3.2' 35 | implementation 'com.journeyapps:zxing-android-embedded:3.6.0' 36 | implementation 'org.bitcoinj:bitcoinj-core:0.14.7' 37 | implementation project(path: ':librarysdkew') 38 | } 39 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/info/bcdev/easytoken/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package info.bcdev.easytoken; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Assert; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * @see Testing documentation 15 | */ 16 | @RunWith(AndroidJUnit4.class) 17 | public class ExampleInstrumentedTest { 18 | @Test 19 | public void useAppContext() throws Exception { 20 | // Context of the app under test. 21 | Context appContext = InstrumentationRegistry.getTargetContext(); 22 | 23 | Assert.assertEquals("info.bcdev.easytoken", appContext.getPackageName()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/java/info/bcdev/easytoken/MainActivity.java: -------------------------------------------------------------------------------- 1 | package info.bcdev.easytoken; 2 | 3 | import android.app.Dialog; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.view.View; 9 | import android.widget.EditText; 10 | import android.widget.ImageView; 11 | import android.widget.SeekBar; 12 | import android.widget.TextView; 13 | 14 | import com.google.zxing.integration.android.IntentIntegrator; 15 | import com.google.zxing.integration.android.IntentResult; 16 | 17 | import org.web3j.crypto.CipherException; 18 | import org.web3j.crypto.Credentials; 19 | import org.web3j.protocol.Web3j; 20 | import org.web3j.protocol.core.methods.response.EthSendTransaction; 21 | import org.web3j.protocol.core.methods.response.TransactionReceipt; 22 | import org.web3j.utils.Convert; 23 | 24 | import java.io.File; 25 | import java.io.IOException; 26 | import java.math.BigDecimal; 27 | import java.math.BigInteger; 28 | import java.util.Map; 29 | import java.util.concurrent.ExecutionException; 30 | 31 | import info.bcdev.librarysdkew.GetCredentials; 32 | import info.bcdev.librarysdkew.interfaces.callback.CBBip44; 33 | import info.bcdev.librarysdkew.interfaces.callback.CBGetCredential; 34 | import info.bcdev.librarysdkew.interfaces.callback.CBLoadSmartContract; 35 | import info.bcdev.librarysdkew.interfaces.callback.CBSendingEther; 36 | import info.bcdev.librarysdkew.interfaces.callback.CBSendingToken; 37 | import info.bcdev.librarysdkew.smartcontract.LoadSmartContract; 38 | import info.bcdev.librarysdkew.utils.InfoDialog; 39 | import info.bcdev.librarysdkew.utils.ToastMsg; 40 | import info.bcdev.librarysdkew.utils.qr.Generate; 41 | import info.bcdev.librarysdkew.utils.qr.ScanIntegrator; 42 | import info.bcdev.librarysdkew.wallet.Balance; 43 | import info.bcdev.librarysdkew.wallet.SendingEther; 44 | import info.bcdev.librarysdkew.wallet.SendingToken; 45 | import info.bcdev.librarysdkew.wallet.generate.Bip44; 46 | import info.bcdev.librarysdkew.web3j.Initiate; 47 | 48 | /** 49 | * 50 | * @author Dmitry Markelov 51 | * Telegram group: https://t.me/joinchat/D62dXAwO6kkm8hjlJTR9VA 52 | * 53 | * Copyright (C) 2010 The Android Open Source Project 54 | * 55 | * Licensed under the Apache License, Version 2.0 (the "License"); 56 | * you may not use this file except in compliance with the License. 57 | * You may obtain a copy of the License at 58 | * 59 | * http://www.apache.org/licenses/LICENSE-2.0 60 | * 61 | * Unless required by applicable law or agreed to in writing, software 62 | * distributed under the License is distributed on an "AS IS" BASIS, 63 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 64 | * See the License for the specific language governing permissions and 65 | * limitations under the License. 66 | * 67 | * Если есть вопросы, отвечу в телеграме 68 | * If you have any questions, I will answer the telegram 69 | * 70 | * Russian: 71 | * Пример включает следующие функции: 72 | * - Получаем адрес кошелька 73 | * - Получаем баланс Eth 74 | * - Получаем баланс Токена 75 | * - Получаем название Токена 76 | * - Получаем символ Токена 77 | * - Получаем адрес Контракта Токена 78 | * - Получаем общее количество выпущеных Токенов 79 | * 80 | * 81 | * English: 82 | * The example includes the following functions: 83 | * - Get address wallet 84 | * - Get balance Eth 85 | * - Get balance Token 86 | * - Get Name Token 87 | * - Get Symbol Token 88 | * - Get contract Token address 89 | * - Get supply Token 90 | * 91 | */ 92 | 93 | public class MainActivity extends AppCompatActivity implements CBGetCredential, CBLoadSmartContract, CBBip44, CBSendingEther, CBSendingToken { 94 | 95 | private String mNodeUrl = config.addressethnode(2); 96 | 97 | private String mPasswordwallet = config.passwordwallet(); 98 | 99 | private String mSmartcontract = config.addresssmartcontract(1); 100 | 101 | TextView ethaddress, ethbalance, tokenname, tokensymbol, tokensupply, tokenaddress, tokenbalance, tokensymbolbalance, seedcode; 102 | TextView tv_gas_limit, tv_gas_price, tv_fee; 103 | EditText sendtoaddress, sendtokenvalue, sendethervalue; 104 | 105 | ImageView qr_small, qr_big; 106 | 107 | final Context context = this; 108 | 109 | IntentIntegrator qrScan; 110 | 111 | private Web3j mWeb3j; 112 | 113 | private File keydir; 114 | 115 | private Credentials mCredentials; 116 | 117 | private InfoDialog mInfoDialog; 118 | 119 | private BigInteger mGasPrice; 120 | 121 | private BigInteger mGasLimit; 122 | 123 | private SendingEther sendingEther; 124 | 125 | private SendingToken sendingToken; 126 | 127 | private ToastMsg toastMsg; 128 | 129 | @Override 130 | protected void onCreate(Bundle savedInstanceState) { 131 | super.onCreate(savedInstanceState); 132 | setContentView(R.layout.activity_main); 133 | 134 | mInfoDialog = new InfoDialog(this); 135 | 136 | ethaddress = (TextView) findViewById(R.id.ethaddress); // Your Ether Address 137 | ethbalance = (TextView) findViewById(R.id.ethbalance); // Your Ether Balance 138 | 139 | tokenname = (TextView) findViewById(R.id.tokenname); // Token Name 140 | tokensymbol = (TextView) findViewById(R.id.tokensymbol); // Token Symbol 141 | tokensupply = (TextView) findViewById(R.id.tokensupply); // Token Supply 142 | tokenaddress = (TextView) findViewById(R.id.tokenaddress); // Token Address 143 | tokenbalance = (TextView) findViewById(R.id.tokenbalance); // Token Balance 144 | tokensymbolbalance = (TextView) findViewById(R.id.tokensymbolbalance); 145 | seedcode = (TextView) findViewById(R.id.seedcode); 146 | 147 | sendtoaddress = (EditText) findViewById(R.id.sendtoaddress); // Address for sending ether or token 148 | 149 | sendtokenvalue = (EditText) findViewById(R.id.SendTokenValue); // Ammount token for sending 150 | sendethervalue = (EditText) findViewById(R.id.SendEthValue); // Ammount ether for sending 151 | 152 | qr_small = (ImageView)findViewById(R.id.qr_small); 153 | 154 | qrScan = new IntentIntegrator(this); 155 | 156 | tv_gas_limit = (TextView) findViewById(R.id.tv_gas_limit); 157 | tv_gas_price = (TextView) findViewById(R.id.tv_gas_price); 158 | tv_fee = (TextView) findViewById(R.id.tv_fee); 159 | 160 | final SeekBar sb_gas_limit = (SeekBar) findViewById(R.id.sb_gas_limit); 161 | sb_gas_limit.setOnSeekBarChangeListener(seekBarChangeListenerGL); 162 | final SeekBar sb_gas_price = (SeekBar) findViewById(R.id.sb_gas_price); 163 | sb_gas_price.setOnSeekBarChangeListener(seekBarChangeListenerGP); 164 | 165 | GetFee(); 166 | 167 | getWeb3j(); 168 | 169 | toastMsg = new ToastMsg(); 170 | 171 | //keydir = this.getFilesDir("/keystore/"); 172 | 173 | keydir = this.getFilesDir(); 174 | 175 | File[] listfiles = keydir.listFiles(); 176 | if (listfiles.length == 0 ) { 177 | 178 | CreateWallet(); 179 | 180 | } else { 181 | 182 | getCredentials(keydir); 183 | } 184 | } 185 | 186 | public void onClick(View view) { 187 | switch (view.getId()) { 188 | case R.id.SendEther: 189 | sendEther(); 190 | break; 191 | case R.id.SendToken: 192 | sendToken(); 193 | break; 194 | case R.id.qr_small: 195 | final Dialog dialog = new Dialog(context); 196 | dialog.setContentView(R.layout.qr_view); 197 | qr_big = (ImageView) dialog.findViewById(R.id.qr_big); 198 | qr_big.setImageBitmap(new Generate().Get(getEthAddress(),600,600)); 199 | dialog.show(); 200 | break; 201 | case R.id.qrScan: 202 | new ScanIntegrator(this).startScan(); 203 | break; 204 | } 205 | } 206 | 207 | /* Create Wallet */ 208 | private void CreateWallet(){ 209 | Bip44 bip44 = new Bip44(); 210 | bip44.registerCallBack(this); 211 | bip44.execute(mPasswordwallet); 212 | mInfoDialog.Get("Wallet generation", "Please wait few seconds"); 213 | } 214 | 215 | @Override 216 | public void backGeneration(Map result, Credentials credentials) { 217 | mCredentials = credentials; 218 | setEthAddress(result.get("address")); 219 | setEthBalance(getEthBalance()); 220 | setSeed(result.get(seedcode)); 221 | new SaveWallet(keydir,mCredentials,mPasswordwallet).execute(); 222 | mInfoDialog.Dismiss(); 223 | } 224 | 225 | private void setSeed(String seed){ 226 | seedcode.setText(seed); 227 | } 228 | /* End Create Wallet*/ 229 | 230 | /* Get Web3j*/ 231 | private void getWeb3j(){ 232 | new Initiate(mNodeUrl); 233 | mWeb3j = Initiate.sWeb3jInstance; 234 | } 235 | 236 | /* Get Credentials */ 237 | private void getCredentials(File keydir){ 238 | File[] listfiles = keydir.listFiles(); 239 | try { 240 | mInfoDialog.Get("Load Wallet","Please wait few seconds"); 241 | GetCredentials getCredentials = new GetCredentials(); 242 | getCredentials.registerCallBack(this); 243 | getCredentials.FromFile(listfiles[0].getAbsolutePath(),mPasswordwallet); 244 | } catch (IOException e) { 245 | e.printStackTrace(); 246 | } catch (CipherException e) { 247 | e.printStackTrace(); 248 | } 249 | } 250 | 251 | @Override 252 | public void backLoadCredential(Credentials credentials) { 253 | mCredentials = credentials; 254 | mInfoDialog.Dismiss(); 255 | LoadWallet(); 256 | } 257 | /* End Get Credentials */ 258 | 259 | private void LoadWallet(){ 260 | setEthAddress(getEthAddress()); 261 | setEthBalance(getEthBalance()); 262 | GetTokenInfo(); 263 | } 264 | 265 | /* Get Address Ethereum */ 266 | private String getEthAddress(){ 267 | return mCredentials.getAddress(); 268 | } 269 | 270 | /* Set Address Ethereum */ 271 | private void setEthAddress(String address){ 272 | ethaddress.setText(address); 273 | qr_small.setImageBitmap(new Generate().Get(address,200,200)); 274 | } 275 | 276 | private String getToAddress(){ 277 | return sendtoaddress.getText().toString(); 278 | } 279 | 280 | private void setToAddress(String toAddress){ 281 | sendtoaddress.setText(toAddress); 282 | } 283 | 284 | /* Get Balance */ 285 | private String getEthBalance(){ 286 | try { 287 | return new Balance(mWeb3j,getEthAddress()).getInEther().toString(); 288 | } catch (ExecutionException e) { 289 | e.printStackTrace(); 290 | } catch (InterruptedException e) { 291 | e.printStackTrace(); 292 | } 293 | return null; 294 | } 295 | 296 | /* Get Send Ammount */ 297 | private String getSendEtherAmmount(){ 298 | return sendethervalue.getText().toString(); 299 | } 300 | 301 | private String getSendTokenAmmount(){ 302 | return sendtokenvalue.getText().toString(); 303 | } 304 | 305 | /* Set Balance */ 306 | private void setEthBalance(String ethBalance){ 307 | ethbalance.setText(ethBalance); 308 | } 309 | 310 | public void GetFee(){ 311 | setGasPrice(getGasPrice()); 312 | setGasLimit(getGasLimit()); 313 | 314 | BigDecimal fee = BigDecimal.valueOf(mGasPrice.doubleValue()*mGasLimit.doubleValue()); 315 | BigDecimal feeresult = Convert.fromWei(fee.toString(),Convert.Unit.ETHER); 316 | tv_fee.setText(feeresult.toPlainString() + " ETH"); 317 | } 318 | 319 | private String getGasPrice(){ 320 | return tv_gas_price.getText().toString(); 321 | } 322 | 323 | private void setGasPrice(String gasPrice){ 324 | mGasPrice = Convert.toWei(gasPrice,Convert.Unit.GWEI).toBigInteger(); 325 | } 326 | 327 | private String getGasLimit() { 328 | return tv_gas_limit.getText().toString(); 329 | } 330 | 331 | private void setGasLimit(String gasLimit){ 332 | mGasLimit = BigInteger.valueOf(Long.valueOf(gasLimit)); 333 | } 334 | 335 | /*Get Token Info*/ 336 | private void GetTokenInfo(){ 337 | LoadSmartContract loadSmartContract = new LoadSmartContract(mWeb3j,mCredentials,mSmartcontract,mGasPrice,mGasLimit); 338 | loadSmartContract.registerCallBack(this); 339 | loadSmartContract.LoadToken(); 340 | } 341 | 342 | /* Get Token*/ 343 | @Override 344 | public void backLoadSmartContract(Map result) { 345 | setTokenBalance(result.get("tokenbalance")); 346 | setTokenName(result.get("tokenname")); 347 | setTokenSymbol(result.get("tokensymbol")); 348 | setTokenAddress(result.get("tokenaddress")); 349 | setTokenSupply(result.get("totalsupply")); 350 | } 351 | 352 | private void setTokenBalance(String value){ 353 | tokenbalance.setText(value); 354 | } 355 | 356 | private void setTokenName(String value){ 357 | tokenname.setText(value); 358 | } 359 | 360 | private void setTokenSymbol(String value){ 361 | tokensymbol.setText(value); 362 | } 363 | 364 | private void setTokenSupply(String value){ 365 | tokensupply.setText(value); 366 | } 367 | 368 | private void setTokenAddress(String value){ 369 | tokenaddress.setText(value); 370 | } 371 | /* End Get Token*/ 372 | 373 | /* Sending */ 374 | private void sendEther(){ 375 | sendingEther = new SendingEther(mWeb3j, 376 | mCredentials, 377 | getGasPrice(), 378 | getGasLimit()); 379 | sendingEther.registerCallBack(this); 380 | sendingEther.Send(getToAddress(),getSendEtherAmmount()); 381 | } 382 | 383 | @Override 384 | public void backSendEthereum(EthSendTransaction result) { 385 | toastMsg.Long(this,result.getTransactionHash()); 386 | LoadWallet(); 387 | } 388 | 389 | private void sendToken(){ 390 | sendingToken = new SendingToken(mWeb3j, 391 | mCredentials, 392 | getGasPrice(), 393 | getGasLimit()); 394 | sendingToken.registerCallBackToken(this); 395 | sendingToken.Send(mSmartcontract,getToAddress(),getSendTokenAmmount()); 396 | } 397 | 398 | @Override 399 | public void backSendToken(TransactionReceipt result) { 400 | toastMsg.Long(this,result.getTransactionHash()); 401 | LoadWallet(); 402 | } 403 | /* End Sending */ 404 | 405 | /* QR Scan */ 406 | @Override 407 | public void onActivityResult(int requestCode, int resultCode, Intent data) { 408 | IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); 409 | if (result != null) { 410 | if (result.getContents() == null) { 411 | toastMsg.Short(this, "Result Not Found"); 412 | } else { 413 | setToAddress(result.getContents()); 414 | toastMsg.Short(this, result.getContents()); 415 | } 416 | } else { 417 | super.onActivityResult(requestCode, resultCode, data); 418 | } 419 | } 420 | /* End Q Scan */ 421 | 422 | /* SeekBar Listener */ 423 | private SeekBar.OnSeekBarChangeListener seekBarChangeListenerGL = new SeekBar.OnSeekBarChangeListener() { 424 | @Override 425 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 426 | GetGasLimit(String.valueOf(seekBar.getProgress()*1000+42000)); 427 | } 428 | @Override public void onStartTrackingTouch(SeekBar seekBar) { } 429 | @Override public void onStopTrackingTouch(SeekBar seekBar) { } 430 | }; 431 | private SeekBar.OnSeekBarChangeListener seekBarChangeListenerGP = new SeekBar.OnSeekBarChangeListener() { 432 | @Override 433 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 434 | GetGasPrice(String.valueOf(seekBar.getProgress()+12)); 435 | } 436 | @Override public void onStartTrackingTouch(SeekBar seekBar) { } 437 | @Override public void onStopTrackingTouch(SeekBar seekBar) { } 438 | }; 439 | 440 | public void GetGasLimit(String value) { 441 | tv_gas_limit.setText(value); 442 | GetFee(); 443 | } 444 | public void GetGasPrice(String value) { 445 | tv_gas_price.setText(value); 446 | GetFee(); 447 | } 448 | 449 | 450 | /* End SeekBar Listener */ 451 | } 452 | -------------------------------------------------------------------------------- /app/src/main/java/info/bcdev/easytoken/SaveWallet.java: -------------------------------------------------------------------------------- 1 | package info.bcdev.easytoken; 2 | 3 | import android.os.AsyncTask; 4 | 5 | import org.web3j.crypto.CipherException; 6 | import org.web3j.crypto.Credentials; 7 | import org.web3j.crypto.WalletUtils; 8 | 9 | import java.io.File; 10 | import java.io.IOException; 11 | 12 | public class SaveWallet extends AsyncTask{ 13 | 14 | private String mPasswordwallet; 15 | 16 | private File mKeystoredir; 17 | 18 | private Credentials mCredentials; 19 | 20 | public SaveWallet(File keydir, Credentials credentials, String passwordwallet){ 21 | mKeystoredir = keydir; 22 | mCredentials = credentials; 23 | mPasswordwallet = passwordwallet; 24 | } 25 | 26 | @Override 27 | protected Void doInBackground(Void... voids) { 28 | 29 | String FileWallet = null; 30 | try { 31 | FileWallet = WalletUtils.generateWalletFile(mPasswordwallet,mCredentials.getEcKeyPair(), mKeystoredir,false); 32 | } catch (CipherException e) { 33 | e.printStackTrace(); 34 | } catch (IOException e) { 35 | e.printStackTrace(); 36 | } 37 | System.out.println("BIP44 FILE Wallet: "+ FileWallet); 38 | 39 | return null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/info/bcdev/easytoken/config.java: -------------------------------------------------------------------------------- 1 | package info.bcdev.easytoken; 2 | 3 | public class config { 4 | 5 | public static String addressethnode(int node) { 6 | switch(node){ 7 | case 1: 8 | return "http://176.74.13.102:18087"; 9 | case 2: 10 | return "http://192.168.0.33:8547"; 11 | default: 12 | return "https://mainnet.infura.io/avyPSzkHujVHtFtf8xwY"; 13 | } 14 | } 15 | 16 | public static String addresssmartcontract(int contract) { 17 | switch (contract){ 18 | case 1: 19 | return "0x5C456316Da36c1c769FA277cE677CB8F690c5767"; 20 | default : 21 | return "0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7"; 22 | } 23 | } 24 | 25 | public static String passwordwallet() { 26 | return ""; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 19 | 20 | 25 | 26 | 27 | 32 | 33 | 40 | 41 | 42 | 43 | 48 | 49 | 53 | 54 | 59 | 60 | 61 | 62 | 66 | 67 | 71 | 72 | 77 | 78 | 82 | 83 | 84 | 88 | 89 | 93 | 94 | 99 | 100 | 105 | 106 | 107 | 111 | 112 | 116 | 117 | 122 | 123 | 124 | 128 | 129 | 133 | 134 | 139 | 140 | 141 | 145 | 146 | 150 | 151 | 156 | 157 | 158 | 162 | 163 | 167 | 168 | 173 | 174 | 175 | 183 | 184 | 191 | 192 | 199 | 200 | 205 | 206 | 214 | 215 | 216 | 223 | 224 | 233 | 234 | 235 | 236 | 237 | 244 | 245 | 252 | 253 | 258 | 259 | 266 | 267 | 272 | 273 | 274 | 281 | 282 | 288 | 289 | 290 | 291 | 292 | 293 | 298 | 299 | 305 | 306 | 313 | 314 | 315 | 319 | 320 | 324 | 325 | 329 | 330 | 337 | 338 |