B4J Tutorial Another Blockchain example

Discussion in 'B4J Tutorials' started by stevel05, Feb 15, 2018.

  1. stevel05

    stevel05 Expert Licensed User

    Here is a port of the code presented as a tutorial here: https://medium.com/programmers-bloc...chain-java-tutorial-from-scratch-6eeed3cb03fa

    It includes examples of blockchain, transactions, wallets and mining.

    I would suggest in the first instance that you follow the tutorial and try to convert the java code your self as there are a few stages that make important points. If you are not sure on the use of Javaobject or the classes it accesses, all the code required is in the attached example so get it from there. There are not many comments in the code, it is all explained in the tutorial. If you are just curious, that's OK too.

    It also requires the BouncyCastle jar from here: https://www.b4x.com/android/forum/threads/share-encrypted-data-with-b4a.35482/. Copy it into your additional libraries folder, if you haven't already.

    It probably took me about 4 hours to pull everything together and get it working, I was pleasantly surprised how straightforward the coding is. I've learnt a lot about the concepts and technology from doing this and I must say, I was expecting something far more complicated.

    I hope you find it useful.

    Update to fix bug alwaysBusy found in post# 5

    30
     

    Attached Files:

    Last edited: Apr 3, 2018
    korshkov, rwblinn, Mashiane and 10 others like this.
  2. swissmade

    swissmade Active Member Licensed User

    Very nice this
     
    stevel05 likes this.
  3. tufanv

    tufanv Expert Licensed User

    Thanks Steve . This is what i was looking for. One of the most important feature of blockchain is the broadcasting between all the nodes as you know. Are you planning to add this to tutorial somehow ?
     
  4. stevel05

    stevel05 Expert Licensed User

    I think that is going to be part of the next tutorial from the site above. When it's added, I'll look at porting it too.
     
    tufanv likes this.
  5. alwaysbusy

    alwaysbusy Expert Licensed User

    I think there may be a typo in your code:

    In StringUtil.java in the getMerkleRoot() method:
    Code:
    for(int i=1; i < previousTreeLayer.size(); i+=2) { // <---------- is step 2
    In BCUtils:
    Code:
    For i = 1 To PreviousTreeLayer.Size - 1
    should be:
    Code:
    For i = 1 To PreviousTreeLayer.Size - 1 step 2
     
    stevel05 likes this.
  6. stevel05

    stevel05 Expert Licensed User

    Thank you, you are correct. Updated in post # 1.
     
  7. swissmade

    swissmade Active Member Licensed User

    Hi Is there anyone who is still working on this?
     
  8. stevel05

    stevel05 Expert Licensed User

    Not as far as I know. For me, it was just an interesting exercise.
     
    swissmade likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice