Author

Topic: Gumawa ng Blockchain gamit ang Programming Languages. (Read 330 times)

hero member
Activity: 2492
Merit: 542
Nice one op matagal ko ng gustong itry tong Phyton pra makagawa ng sariling blockchain napaka interesting na tut ito para sa mga gusto itry pag bakante kasi ako mahilig akong mag explore lalo na programming testing lang den kasi gusto ko lang itry out of curiousity on how it really works.
legendary
Activity: 1778
Merit: 1009
Degen in the Space
Hindi po ako programmer pero parang sa nakikita ko po wala siyang network na pinagkonekan? is that for simulation lang ng hashes per block in blockchain using Raspberry Pi?
--

Exactly!

I hope na sa explanation ni @darklus123 ay mas maintindihan mo yung gusto mong malaman regarding sa ginawa ko. There are kind of modifications kahit sa offline games at ikaw lang ang nakakakit since hindi ito connected sa network.

So basically, ang ginawa ko is still a blockchain pero not connected in the network. This is applicable on my PC only at ako lang ang nag-gegenerate nito. If you want to create a blockchain network, you can easily create one since open source naman lahat ng codings ngayon, kung gusto mo rin na may access yung ibang tao sa pag-browse ng blockchain mo.
hero member
Activity: 1246
Merit: 588
Hindi po ako programmer pero parang sa nakikita ko po wala siyang network na pinagkonekan? is that for simulation lang ng hashes per block in blockchain using Raspberry Pi?

Ganito kasi yan, every system or software na ginagawa will start from using only your own local drives. So basically your code will still completely run kahit na  simulation lng iyan or your final output even without a "Network".

What's the purpose of connecting your system to a network? whether it is Local Are Network, Wide Area Network, World Wide Web which is the Global Network or the Internet. Ang main purpose nyan is to obviously to connect your system or software to other people who shares the same network.

So for example is to what happens to @OP yung nagawa nyang program is not connected to a network so basically siya lng din makakapag test ng program nya. But what if gusto mo rin i try? Dyan na papasok ang network. Pde i upload ni OP yung program nya sa isang hosting at pde kana din mag test through it.

legendary
Activity: 1778
Merit: 1009
Degen in the Space
Hindi po ako programmer pero parang sa nakikita ko po wala siyang network na pinagkonekan? is that for simulation lang ng hashes per block in blockchain using Raspberry Pi?
Like what I've said, it's just a basic one where we can analyze how does the blockchain works. Yes, you need a connection if you wanted to input the network kaso wala naman akong ginamit na connection so there's no network.

I'm not a programmer also, so I made a simple one and source ko ang github if tatanungin mo naman yung codes. The reason why I made this is na-curious lang din ako kung paano at bakit nga ba tinawag na blockchain?
Kasi kung sa tutuusin halos lahat ng advanced technology ay may network, lahat ng makabago ay may netowrk, mapa-IoT man yan, LoRawan, there's a network, kaya understood na yon. Ang point ko lang din dito is para malaman what's inside and how does it simulate hashes.

So for short, there's no network, I hope you understand.

full member
Activity: 210
Merit: 100
busy in real life, long post gap is understandable
Hindi po ako programmer pero parang sa nakikita ko po wala siyang network na pinagkonekan? is that for simulation lang ng hashes per block in blockchain using Raspberry Pi?
legendary
Activity: 1778
Merit: 1009
Degen in the Space
Better try solidity bro or go the path of being a blockchain dev, I've watched some tuts na it is one of the rising job at ang maganda pansa ngayon ay it has low competition compared to other dev jobs. If you're that knowledgeable sa Java I guess gamay mo yung solidity as it is more on classes. I am just a newbie sa programming world but I am trying to learn as I can, because I know this skill might be useful in the future.

I'm just a newbie too, sadyang na-tripan ko lang mag-experiment ng ganito. If something complex like a blockchain for a specific data, sobrang hirap na gawin non. Actually, may research din kami na blockchain about sa data ng university tas sobrang tagal na naming ginagawa pero mababa pa rin ang progress. Diyan sa topic ko, it's just a basic lang talaga. Anyways, thanks! I'll try to work with that kung kakayanin maging matinding programmer.
hero member
Activity: 2030
Merit: 578
No God or Kings, only BITCOIN.
Better try solidity bro or go the path of being a blockchain dev, I've watched some tuts na it is one of the rising job at ang maganda pansa ngayon ay it has low competition compared to other dev jobs. If you're that knowledgeable sa Java I guess gamay mo yung solidity as it is more on classes. I am just a newbie sa programming world but I am trying to learn as I can, because I know this skill might be useful in the future.
legendary
Activity: 1778
Merit: 1009
Degen in the Space
Actually may errors siya nung ginawa ko after ko i-run pero na-fix ko din agad. Pero sa case ng codes na yan, searchable naman yung errors at baka type errors lang kaya hindi nagru-run. Common functions lang naman diyan is yung conditional tas yung definition, kaya advantage na rin siya sa mga may alam. Pero we're willing to help them naman if everytime na may error silang natanggap, i-reply lang nila dito.
Sabagay open source naman halos lahat ng codes sa mga project na blockchain related so may mga discussion or questionos and anwers na sa stackexchange or stockoverflow or github yung mga ganyan.
Happy coding nalang sa mga susubok  Cheesy

Yes, sobrang daming site kahit sa github ka lang tumambay, madaming ka ng makikita na ibat ibang klase at sistema, sila nalang pipili kung ano ang trip nila.

--
Pero bago ang lahat, may mga respective libs pala na kailangang ma-install para magwork yung import. All of it are included naman sa tutorials in github if magta-try kayo.  Cheesy
copper member
Activity: 2142
Merit: 1305
Limited in number. Limitless in potential.
Actually may errors siya nung ginawa ko after ko i-run pero na-fix ko din agad. Pero sa case ng codes na yan, searchable naman yung errors at baka type errors lang kaya hindi nagru-run. Common functions lang naman diyan is yung conditional tas yung definition, kaya advantage na rin siya sa mga may alam. Pero we're willing to help them naman if everytime na may error silang natanggap, i-reply lang nila dito.
Sabagay open source naman halos lahat ng codes sa mga project na blockchain related so may mga discussion or questionos and anwers na sa stackexchange or stockoverflow or github yung mga ganyan.
Happy coding nalang sa mga susubok  Cheesy
legendary
Activity: 1778
Merit: 1009
Degen in the Space
Interesting, never ako nag try gumawa ng owned blockchain ideas even alam ko mag program. Okay na siguro gumawa even ganyan lang, but the thing is hanggang copy paste lang, kase once may criticial error/bugs don't know if kaya ma fix, so need talaga intindihin bawat lines nyan, terms, functions, etc. So far for experience lang, that should be great.

Actually may errors siya nung ginawa ko after ko i-run pero na-fix ko din agad. Pero sa case ng codes na yan, searchable naman yung errors at baka type errors lang kaya hindi nagru-run. Common functions lang naman diyan is yung conditional tas yung definition, kaya advantage na rin siya sa mga may alam. Pero we're willing to help them naman if everytime na may error silang natanggap, i-reply lang nila dito.

Yes experience nalang din, its not for a project naman, since nakaka-curious rin kasi yung mga ganitong bagay.  Cheesy
copper member
Activity: 2142
Merit: 1305
Limited in number. Limitless in potential.
Interesting, never ako nag try gumawa ng owned blockchain ideas even alam ko mag program. Okay na siguro gumawa even ganyan lang, but the thing is hanggang copy paste lang (only sa di programming geek), kase once may criticial error/bugs don't know if kaya ma fix, so need talaga intindihin bawat lines nyan, basics, terms, functions, etc.
So far for experience lang, that should be great achievement.
legendary
Activity: 1778
Merit: 1009
Degen in the Space
So while I'm having a calculation of my research, napaisip nalang ako bigla na what if gumawa ako ng basic na blockchain using Programming Language? I know that some of you already know this pero syempre para sa mga hindi pa nakakaalam and marunong gumamit ng programming language, you can actually try this!

The programming language that I've used is Python but there's a twist on my experiment. Ginagamit ko kasi yung Raspberry Pi ko at the moment so built in with Python na siya, bakit pa ako magta-try sa PC if meron naman sa RPi. For those people na magtatanong kung anong gamit kong model ng Rpi, Raspberry Pi 3 B+ po ang gamit ko.  Wink

Note: It's not necessary to buy an RPI for this experiment, sadyang nagustuhan ko lang since gamit ko siya rn.


So para saan ba ito?


It's a great experience also at madaling gawin and the most important thing is malalaman niyo yung bawat terms kasi alam niyo kung paano nagwowork.

--------
So ito na nga.
I tried the codes that I saw on github and put it on python, and this is the terminal of Raspberry Pi using PuTTy.




These are the codes:
Code:
import datetime
import hashlib

class Block:
    blockNo = 0
    data = None
    next = None
    hash = None
    nonce = 0
    previous_hash = 0x0
    timestamp = datetime.datetime.now()

    def __init__(self, data):
        self.data = data

    def hash(self):
        h = hashlib.sha256()
        h.update(
        str(self.nonce).encode('utf-8') +
        str(self.data).encode('utf-8') +
        str(self.previous_hash).encode('utf-8') +
        str(self.timestamp).encode('utf-8') +
        str(self.blockNo).encode('utf-8')
        )
        return h.hexdigest()

    def __str__(self):
        return "Block Hash: " + str(self.hash()) + "\nBlockNo: " + str(self.blockNo) + "\nBlock Data: " + str(self.data) + "\nHashes: " + str(self.nonce) + "\n--------------"

class Blockchain:

    diff = 20
    maxNonce = 2**32
    target = 2 ** (256-diff)

    block = Block("Genesis")
    dummy = head = block

    def add(self, block):

        block.previous_hash = self.block.hash()
        block.blockNo = self.block.blockNo + 1

        self.block.next = block
        self.block = self.block.next

    def mine(self, block):
        for n in range(self.maxNonce):
            if int(block.hash(), 16) <= self.target:
                self.add(block)
                print(block)
                break
            else:
                block.nonce += 1

blockchain = Blockchain()

for n in range(10):
    blockchain.mine(Block("Block " + str(n+1)))

while blockchain.head != None:
    print(blockchain.head)
    blockchain.head = blockchain.head.next
credits to howCodeORG of github.

The output of the blockchain.py with the diff=20, As you can see it has a huge amount of Hashes.

------------
Block Hash: 099f56cb4679e8269967eb4dd0408f64df67f050c77b10935cb32b7a7958ca11
BlockNo: 1
Block Data: Block 1
Hashes: 161183
------------
Block Hash: d4df2f16e65810d9a8aaae38e004f2b808e335381453e6ad22c7c875c64d55e2
BlockNo: 2
Block Data: Block 2
Hashes: 318974
------------
and so on...

The output of the blockchain.py with the diff=0, the Hashes are 0.
The hash of the block must be less than to the actual target for it to worked.



So this is it! I made a simple blockchain and learned it while trying to make it in my RPi. There are so many amazing codes that are available on github, pwede mong magamit yung python, c+, or java. I'll just want to share this simple thing, thanks for reading!


Jump to: