Code Monkey home page Code Monkey logo

zoeleesss / web3j-android-solidity-example Goto Github PK

View Code? Open in Web Editor NEW
22.0 2.0 5.0 11.76 MB

Everything you need to know about how to make an Ethereum blockchain dapp on android using Solidity, Web3j, Infura, etc.

Home Page: https://fish.cryptokindom.com

License: MIT License

Java 20.10% PHP 0.45% JavaScript 79.29% HTML 0.17%
ethereum blockchain android web3j dapp infura solidity genetic-algorithm web3js metamask php image-processing cfc cryptofancycarps

web3j-android-solidity-example's Introduction

Web3j-Android-Solidity-example

  • This is more than a simple web3j project using solidity.
  • What we are trying to acheive here is to make a dapp game just like cryptokitties but on android which is supposed to be harder since you have to consider many things like wallet and user interface.

Quick Overview

SolidityAndWeb3js

  • The folder contains solidity contracts

    • solidity source code which tells how a Fish( actually, i prefer to call it CryptoFancyCarp ) is made with pieces.
    • Also it is a genetic game which means you can let your fish to mate with others and have baby fish. This, i implemented a genetic algorithm for it. You can also see it here:GeneticConsoleWithSolidity.
    • and other contract using soldity. I put many files together to FishContracts.
  • The folder contains Web3js implementation

    • I already deployed the contract and made a simple web3js file for you to call the functions. I have deployed a webpage just for you. FishDApp
  • Deployment

    • When you deploy the contract, use this FishContracts file. And remember to deploy two contracts: FishCore & GeneticConsole and rememeber to set the address of geneticConsole to fishcore.

PHPServerAPI

  • The folder contains secret fomula of a fish's gene.
    • Gene Quality

      • There are several qualities about genes i created.
      • Start from normal to rare,superior,Godlike, and even to MasterOfUniverse.
      • $names = ['普通','稀有','卓越','史诗','神话','传说','超神','宇宙之主'];
      • Try it yourself here: FishAlphaGene
    • Image

      • There are nearly 200 million possibilities of the outlook of our fishes.
      • Here are some exaples:
      • Fish 1
      • Fish 2
      • Fish 2
      • See more in images folder. Or Try the combination yourself here: FishAlphaImage

AndroidAndWeb3j

  • The folder contains android code & generated contract code
    • Wallet: How to use/create/import Ethereum wallet.
    • FishAPI: How to call,send transaction to a deployed contract
    • Utils: Some useful functions waiting to be explored
    • Others.

Others

  • This file includes everything that i need about my deplyed contract and how i can connect to blockchain.
    • Infura. It has my own Infura API token. You are welcome to use it by any means.
    • Contract address, contract ABI, contract �owner.
    • Web3j simple code to call or send transaction of functions of a contract. You can use them in the chrome console. I deployed my web3j front-end here. Try it out. FishDApp

The processes of Making Your Own Android DAPP

##Soidity First
1. You need to write your own solidity source code.
2. Compile and Deploy your source code using `remix`
(Don't forget to record your contract address! )
##Autogenerate file 
3. Now use your source code( contract.sol )to use `solc` and `web3j` command tool to generate a java file.
##Android
###dependencies
4. Add `compile ('org.web3j:core:3.3.1-android')` to app/build.gradle
###Testing
5. Write and run simple code like creating a wallet
##Done

Tools:

remix

solc (Remeber to use npm install solc to get solc):

Example: solc MetaCoin.sol --bin --abi --optimize -o /Users/pro/Desktop

Format: solc <contract>.sol --bin --abi --optimize -o <output-dir>/

web3j:

Format: web3j solidity generate [--javaTypes|--solidityTypes] /path/to/<smart-contract>.bin /path/to/<smart-contract>.abi -o /path/to/src/main/java -p com.your.organisation.name

Erros during Android development

This is a list a possible error you might encounter, and i may have dealt with them already. So I am gonna share my experience here.

  • Error: Execution failed for task ': app: packageAllDebugClassesForMultiDex'. > Java.util.zip.ZipException: duplicate entry: bolts / AggregateException.class

  • Solution: 1.add multiDexEnabled true to defaultConfig in app/build.gradle. 2.add compile 'com.android.support:multidex:1.0.3' to dependecies in app/build.gradle.

  • java.lang.OutOfMemoryError: Failed to allocate a 268435468 byte allocation with 8050708 free bytes and 244MB until OOM

  • Solution:

  1. When you are trying to create a new wallet. Try String filename = WalletUtils.generateLightNewWalletFile(password,new File(filepath)); 👍 instead of String filename = WalletUtils.generateFullNewWalletFile(password,new File(filepath));
  2. And when you import an old wallet from ECKeyPair, Try String filename = WalletUtils.generateWalletFile(password,ecKeyPair,new File(filepath),false);👍 instead of String filename = WalletUtils.generateWalletFile(password,ecKeyPair,new File(filepath),true);

Contributors - Join us by pulling requests:

Zoe Lee

Jingyuan Ni

Dongqi Shen

Donate here:

Github : ❤❤❤ Stars ❤❤❤ �

Ethereum : 0x94cba7B70800575a3A4BfFd3B195bE4CcF5f7AAd

web3j-android-solidity-example's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.