­
Join Contrib, Build and Earn Equity in your Spare Time
Contribute your Skills,Services,Apps,Contacts or Capital,part-time.Help a team of other passionate people doing amazing things.Come learn and earn!Contribute toblog.contrib.comCLICK BELOW:Challenges

Challenges

  • Contrib Excalibur Nextjs Template Challenge

    Introducing the Concept

    We’re on a quest to create a Next.js template that does two mind-blowing things:

    • Self-updates:Like a mythical creature that regenerates,this template evolves with each contribution.Think of it as a GitHub repo that drinks from the Fountain of Eternal Updates.
    • Central Management:Approved users wield the power to manage the site via our central app on vnoc.com,acting as guardians of this digital realm.

    Why You Should Join This Quest

    • Become a Digital Deity: Leave your mark on a project that could redefine how we think about web templates.

    • Flex Your Next.js Muscles:Show off your skills and possibly learn a new trick or two.

    • Community Glory: Be part of an elite team that dares to dream big and deliver something unique.

    How It Works – The Magic Behind the Curtain

    • The Proposal Arena: Submit your ideas for what this Next.js template could be. A portfolio that updates with your latest GitHub commit? A blog that auto-publishes your midnight musings from a Markdown file? The sky’s the limit.
    • The Forge of Approval: Ideas will be vetted by our team of wise wizards (aka the project admins). If your idea shines brightest, it becomes the chosen one.
    • The Circle of Contributors: Once an idea is selected, it’s all hands on deck. Contribute code, documentation, spells, and potions (okay, maybe not potions) to bring the concept to life.
    • The Command Center: Approved guardians (that’s you, if you wish) can manage the site directly from vnoc.com, ensuring the template remains not only a beacon of innovation but also a fortress of security and efficiency.

    Your Call to Action

    • Contribute Your Idea:Have a concept that fits our mission?Share it!Your brainchild could lead the charge.

    • Lend Your Skills: Whether it’s coding, design, documentation, or offering moral support, there’s a place for you.

    • Spread the Word:Know a fellow coder who’s itching for a challenge?Bring them into the fold!

    Ready to Make History?

    EP:0

    APPLY
  • Fine me a Bug

    This is a test challenge

    EP:0

    APPLY
  • Fanchallenge.com

    FanChallenge is a blockchain-based game that allows fans to compete against each other in a variety of challenges related to their favorite sports teams and athletes.Players earn rewards in the form of digital tokens by participating in challenges and climbing the leaderboard with your favorite profile.


    EP:0

    APPLY
  • Reply Challenge Code


    The Reply Code Challenge Standard edition is a team-based coding competition open to students and professional coders aged 16 or older

    EP:0

    APPLY
  • REGISTER AND WATCH Contrib WEBINAR CHALLENGE

    Signup for a Contrib account.Register and Secure an Event pass to Watch Webinar on Contribution Side Hustle for Free Blockchain Tokens. Takea screenshot of the Invite and the Webinar Video you’re watching.GET CTB tokens

    EP:50

    APPLY
  • Realtydao Install and Connect Challenge

    Sign up for a Realtydao account. 

    To Sign Up follow these steps.click on the link below

    https:

    EP:50

    APPLY
  • CONTRIB INSTALL AND CONNECT CHALLENGE

    Signup for a Contrib account.Install Metamask and Connect wallet to your Contrib account Take a screenshot.GET CTB tokens

    EP:50

    APPLY
  • Help Us Create The First Contributor Produced Webinar

    These are the contributor slots.You can choose which of these contributor scripts you will be producing in your video.

    EP:0

    APPLY
  • Diva Singer Challenge

    This is a challenge to all aspiring Divas.

    EP:0

    APPLY
  • Groupie Challenge

    In this GROUPIE CHALLENGE,we're looking to become the ultimate groupie!You will need to get a bunch of views on your youtube channel,join contrib team,and then marry someone who is on that team.We've got tips on all of these things in out Groupie Challenge Guide below.

    EP:0

    APPLY
  • CHALLENGE YOUR IDEA

     Use your creativity and critical thinking to solve a challenge set by us.You’ll be assigned to a team in advance and by the end of the year, you’ll present a short video pitch and show us how you’d solve your own idea challenge.

    EP:0

    APPLY
  • Tiktok Challenge

    Create a Tiktok video challenge for Contrib and send us your best Tiktok video using the Contrib platform.

    Be as unique, provocative as Tiktokers go!

    The winner will win cash and CTB tokens!

    EP:0

    APPLY
  • Best Christmas decor-with recycling theme

    Create a Christmas décor based on recycled materials 

    EP:0

    APPLY
  • 305challenge.com

    Play To Own and Test your IQ and Action Stills to Make an Impact on 305.

    EP:0

    APPLY
  • PompChallenge-Play to Own,Challenge the Bros

    Join the challenge today and test how well you stack up against the Pomp Brothers.

    EP:0

    APPLY
  • Meme Challenge

    Create the most legendary meme about RDAO.Post a link to your original meme in the comments.

    EP:0

    APPLY
  • PRESS CHALLENGE

    PRChallenge,a website under Ichallenge and recently acquired by RealtyDao.com launches it's very first PR challenge for RealtyDao soft Beta Launch.


    EP:0

    APPLY
  • Viruschallenge.com

    Facts and Stats regarding the CoronaVirus. Lead and Inform others while contributing other challenges to help solve and resolve our livelihood. 

    EP:0

    APPLY
  • Test Your Money Smarts Challenge

    Click on the correct answer.If you don't know the answer,click on"don't know."

    EP:0

    APPLY
  • EventChallenge is a game that rewards hosts for putting on great events and gatherings.

    EventChallenge is a game that rewards hosts for putting on great events and gatherings. The Challenge is to create the best story board and execute upon that where your event participants provide feedback on your execution and expectations. Everyone's time is valuable,attending events that suck,should be documented while great events should be rewarded.  EventChallenge is learning and growing around event driven experiences.

    EP:0

    APPLY
  • City vs City-Boca vs Austin

    City Challenge is a gamification platform and feedback mechanism for activity and connection for communities around the world. 

    EP:0

    APPLY
  • Referral Intro Challenge

    LIsten to these 2 big crypto pioneers talking about how domains should be valued in the next couple of years.

    We believe we have the next big thing and we just need sound advice from these two giants.

    All we need is an introduction to any of these two guys and we will give you 1%ESH(eShares)of referrals.com.


    EP:0

    APPLY
  • Home Challenge

    The historic Kessler Mansion,KesslerMansion.com,located at 4923 Kessler Blvd East Drive in Indianapolis is a 26,000 sq ft.private estate being redeveloped into a group travel,event space with advanced smart house capabilities. We are seeking strategic partners to leverage the asset and create revenues and value with a 2-5 year exit plan.Managed by RealtyLink,Inc.The estate is 12 minutes from downtown Indianapolis and 5 Minutes to Broadripple or Castleton. In 2013,The estate was home to VentureCamp in which 22 people live/worked at the estate for 2 months.It has since been vacant and is now being developed as a rental unit for travelers,corporate guest and private events.The product offering is targeted at large groups or families along with event space for fundraisers and events. Below is a general offering opportunity with the vision of becoming the most unique and fully utilized property that helps its guests,Make Moments Matter..

    EP:0

    APPLY
  • ARChallenge

    Create the leading avatar for ARChallenge around our partner EarthChallenge..Fruit,fish,Birds,etc.Challenge compliment is creating intelligence behind the avatar entity. 

    EP:10000

    APPLY
  • Welcome to dockerchallenge.com

    Set up,Execute Data Sets to predict outputs for customers. Learn,Earn and Contribute with other like minded professionals.

    EP:1

    APPLY
  • FruitChallenge

    fruitchallenge is a educational game to entertain people to eat healthy.fruitchallenge also is to keep children and adults healthy and to know what fruits are good to eat.

    EP:0

    APPLY
  • Red Tide

    RedTideChallenge is a game to educate residents about the cause and effect of this organism effecting our Oceans.  We hope others act today to help address and stop the issue.

    EP:25

    APPLY
  • Fishy quiz

    Its a fishy challenge.

    EP:0

    APPLY
  • Realty Challenge

    So what do you know about Real Estate?Here are Real Estate trivia questions to see how well and how much you know about Real Estate!

    EP:0

    APPLY
  • 305challenge.com

    Play to Own Game focused on Environmental and Technology Issues and Solutions.

    EP:0

    APPLY
  • Realty Challenge

    How much do you know about real estate—and real-estate investing?

    EP:0

    APPLY
  • Reduce,Reuse,Recycle by EarthChallenge

    Reduce- the amount of resources and supplies needed to maintain an optimal value proposition to our customers, our operations and our environment.


    Reuse-We have both an incinerator and a compactor to maximize the size and usage of our waste footprint. We plan on creating an energy redistribution systems including energy systems with our EnergyStorage.com asset,Food Systems and waste systems.


    Recycle-  Separating  all remaining cardboard, plastics other recycling options used on board.



    What-Platform for Effective Change using Gamification and Personalized Ecosystems

       Why- Climate Change- DO something BIG, NOW to protect the Oceans, Air and Earth

        How-Technology,Process,Strategy,Business Models,Communications,Transparency

       Who- Passionate Entrepreneurs, Techies, Burners and other Professionals

    When- Oct- Funding, Nov- Dev/Ops,September-Open,2022-2023-Getting After it

    Where-Phase 1,Key West on a self contained 75,000 sq.ft.vessel called(EARTH)

       Impact Programs-


    Next Steps-  Help us spread the word and engage others that can help by joining using our referral platform or joining today. (JoinNOw)

    EP:1000000

    APPLY
  • Welcome to coinchallenge.com

    CoinChallenge is a crypto game to bet coins against coins or assets verses assets based on timing and value mechanisms.

    EP:1000

    APPLY
  • Carbonchallenge.com

    Carbon Challenge is a game to save the worlds rainforest,ocean,lands and air through a self running game around carbon and carbon credits.

    EP:100

    APPLY
  • TrumpChallenge

    When will trump say crypto currency in the media?

    Take our TrumpChallenge, guess right day/time and win great stuff. 

    EP:10

    APPLY
  • QuantumChallenge

    QuantumChallenge is a leading education and solutions platform for quantum based experts working on moonshot projects.

    EP:20

    APPLY
  • RubyChallenge.com

    RubyCHallenge is a testing ground for talented individuals to showcase there skills.

    EP:1000

    APPLY
  • ETHChallenge

    EthChallenge is a leading code and concept redistribution platform expanding on work started and not completed at the hottest hackathons around the world.  2%of the eshares cap table are pledged to the Ethereum Foundation for program repurposing.

    EP:1000

    APPLY
  • Welcome to pizzachallenge.com

    PizzaChallenge is the first game to win free pizza from the BEST pizza providers in town.

    EP:0

    APPLY
  • EU Funding for Eurozone.com

    Take a look at the 2 links to the EU grant sources in this challenge.Select the best 3 programmes and tell us why we should apply for a grant for our digital venture www.eurozone.com

    EP:100

    APPLY
  • Leeds City Internet of Things

    Write 10 sentences about how you think Leeds City can innovate and build smarter houses.

    Think about uses and applications for the Internet of Things in your proposal outline.

    EP:0

    APPLY
  • UK Tech&Start Up Challenge

    London New Tech presents entrepreneurs and their ideas every month in the heart of the British capital.

    LNT has over 10 000 members on Meet Up and is always keen to promote the latest innovation and business models.

    EP:100

    APPLY
  • Law Tech

    In 10 sentences or less,come up with a description of how to deploy a LawyerBot within an app or software used in Law Tech.

    It could be an avatar doing a job or an AI application so the bot is transactional, does research or data mining...

    EP:100

    APPLY
  • LDN Business Show

    Can you answer these questions about the London Business Show?Answers can be found on the LEN website and the LBS Meet Up group information...

    EP:100

    APPLY
  • Eurozone Quiz

    Please answer these questions and we will get back to you with your score and an appraisal!


    EP:100

    APPLY
  • BotChallenge

    Who can build the best autonomous application or bot,that will power the leading bot url brands.

    EP:100

    APPLY
  • Vegetable Diet Challenge

    This is a healthy vegetable diet challenge for 3 days


    EP:10

    APPLY
  • Code challenge

    Join Now and play some amazing code challenges

    EP:4000

    APPLY
  • Team Challenge

    Our first of many Brand-a-thons we will be conducting in the next couple of months using our Contrib/VNOC tools,platform and model.

    EP:500

    APPLY
  • Entrepreneurs Challenge

    Join the entrepreneurs building the business forEuroChallenge.com! Join and complete the quiz below.

    EP:50

    APPLY
  • Selfie Video Challenge

    Join the entrepreneurs building the business for eurodesign.com!Send us a 1 minute video to tell us what you can bring to the table.

    EP:2000

    APPLY
  • Debugging Challenge

    Debugging Challenge

    EP:0

    APPLY
  • Welcome to codechallenge.com

    Submit Your Framework For Partner-Distribution, Co-foundership and Passive Revenue

    EP:4000

    APPLY
  • NativeQuiz

    NativeQuiz is the Industry testing ground for Native Ads.

    EP:5

    APPLY
  • Work Challenge

    Are you awesome at value creation output? Earn a years salary in a weeks time by winning our weekly Work Challenge. We have 10 positions we'll be doing and giving away a years'worth of salary to the best of the best. Come learn and Earn.

    EP:10000

    APPLY
  • Fitnesschallenge.com

    Measuring Fitness with your Friends

    EP:100

    APPLY
  • MBAChallenge

    MBAChallenge is the leading business game created for to elevate education

    EP:100

    APPLY
  • BoulderChallenge

    BoulderChallenge requires Talent,Knowledge and Luck. Find out who is the best in boulder.

    EP:100

    APPLY
  • Contrib Video Challenge

    All you need to do is Create a jumpcam video and share with friends!

    This is a sample of video created by jumpcam!

    https:

    EP:5

    APPLY
  • Text to Picture Challenge

    Create a simple web application that allows you to return a single image when you type in a keyword.

    Use Github for your application and we will need a live url for demo purposes.



    EP:100

    APPLY
  • Survey Mobile App

    Develop innovative mobile applications for today’s most pressing societal needs.
    Win cash prizes,network,and build your skillset,all while changing the world for the better.

    Compete with your fellow colleagues for a shot at the grand prize and earn bragging rights.


    EP:500

    APPLY
  • The Daily Photo Challenge

    Publish a new post with a photo interpreting the daily theme. 

    EP:5

    APPLY
  • GovChallenge

    Issues with Local gov.problems

    EP:10

    APPLY
  • Venturechallenge.com

    20 People,6 days,1 private estate,building awesome industry focused business ventures. 

    Business is the ultimate sport.  Play our various challenges and earn equity and cash grants for top performance. Come Learn and Earn.

    EP:100

    APPLY
  • Social-challenge.com

    Seeking to find the worlds best actors,and actresses and Challenge them with other like minded people.

    1. Prepare a short video
    2. Attach them to your entry application
    3. Tweet it with mention of https://twitter.com/talentchallenge
    4. Like us on Facebook - https://www.facebook.com/pages/Talentchallenge/1448432865386981

    EP:99

    APPLY
  • Content Challenge

    Do you have an idea for a content site that will allow writers and bloggers to publish their content-it may be media,articles,press release and can be syndicated to any of the 20k brands or any brand for that matter.

    EP:200

    APPLY
  • Social Challenge

    Social Media Experts-Please Stand Up!.

    EP:5000

    APPLY
  • Design Challenge

    Only for Design Guru's and Aspiring Design Hacks!

    EP:5000

    APPLY
  • PR Challenge

    If you're a press release superstar,writer and Ninja,then this Challenge is for you!

    We need to get this news syndicated :

    https:

    EP:10000

    APPLY
  • Survey Challenge

    A revolutionary Q&A framework that features gamification strategies,community and social interaction models around Facebook,Twitter and urls.

    EP:1000

    APPLY
  • Media Challenge

    Do you think you got great video editing skills?Are you the web's next video superstar?

    EP:1000

    APPLY
  • Mobile Challenge

    Submit mobile apps that could run our mobile vertical.We have over 265 brands that has over 50k views monthly.

    EP:20000

    APPLY

Learn Blockchains by Building One

The fastest way to learn how Blockchains work is to build one.

You’re here because, like me, you’re psyched about the rise of Cryptocurrencies. And you want to know how Blockchains work—the fundamental technology behind them.

But understanding Blockchains isn’t easy—or at least wasn’t for me. I trudged through dense videos, followed porous tutorials, and dealt with the amplified frustration of too few examples.

I like learning by doing. It forces me to deal with the subject matter at a code level, which gets it sticking. If you do the same, at the end of this guide you’ll have a functioning Blockchain with a solid grasp of how they work.

Before you get started…

Remember that a blockchain is an immutable, sequential chain of records called Blocks. They can contain transactions, files or any data you like, really. But the important thing is that they’re chained together using hashes.

If you aren’t sure what a hash is, here’s an explanation.

Who is this guide aimed at? You should be comfy reading and writing some basic Python, as well as have some understanding of how HTTP requests work, since we’ll be talking to our Blockchain over HTTP.

What do I need? Make sure that Python 3.6+ (along with pip) is installed. You’ll also need to install Flask and the wonderful Requests library:

pip install Flask==0.12.2 requests==2.18.4

Oh, you’ll also need an HTTP Client, like Postman or cURL. But anything will do.

Where’s the final code? The source code is available here.


Step 1: Building a Blockchain

Open up your favourite text editor or IDE, personally I ❤️ PyCharm. Create a new file, called blockchain.py. We’ll only use a single file, but if you get lost, you can always refer to the source code.

Representing a Blockchain

We’ll create a Blockchain class whose constructor creates an initial empty list (to store our blockchain), and another to store transactions. Here’s the blueprint for our class:

Blueprint of our Blockchain Class

Our Blockchain class is responsible for managing the chain. It will store transactions and have some helper methods for adding new blocks to the chain. Let’s start fleshing out some methods.

What does a Block look like?

Each Block has an index, a timestamp (in Unix time), a list of transactions, a proof (more on that later), and the hash of the previous Block.

Here’s an example of what a single Block looks like:

Example of a Block in our Blockchain

At this point, the idea of a chain should be apparent—each new block contains within itself, the hash of the previous Block. This is crucial because it’s what gives blockchains immutability: If an attacker corrupted an earlier Block in the chain then all subsequent blocks will contain incorrect hashes.

Does this make sense? If it doesn’t, take some time to let it sink in—it’s the core idea behind blockchains.

Adding Transactions to a Block

We’ll need a way of adding transactions to a Block. Our new_transaction()method is responsible for this, and it’s pretty straight-forward:

After new_transaction() adds a transaction to the list, it returns the index of the block which the transaction will be added to—the next one to be mined.This will be useful later on, to the user submitting the transaction.

Creating new Blocks

When our Blockchain is instantiated we’ll need to seed it with a genesis block—a block with no predecessors. We’ll also need to add a “proof” to our genesis block which is the result of mining (or proof of work). We’ll talk more about mining later.

In addition to creating the genesis block in our constructor, we’ll also flesh out the methods for new_block()new_transaction() and hash():

The above should be straight-forward—I’ve added some comments and docstrings to help keep it clear. We’re almost done with representing our blockchain. But at this point, you must be wondering how new blocks are created, forged or mined.

Understanding Proof of Work

A Proof of Work algorithm (PoW) is how new Blocks are created or mined on the blockchainThe goal of PoW is to discover a number which solves a problem. The number must be difficult to find but easy to verify—computationally speaking—by anyone on the network. This is the core idea behind Proof of Work.

We’ll look at a very simple example to help this sink in.

Let’s decide that the hash of some integer x multiplied by another y must end in 0. So, hash(x * y) = ac23dc...0. And for this simplified example, let’s fix x = 5. Implementing this in Python:

from hashlib import sha256
x = 5
y = 0  # We don't know what y should be yet...
while sha256(f'{x*y}'.encode()).hexdigest()[-1] != "0":
    y += 1
print(f'The solution is y = {y}')

The solution here is y = 21. Since, the produced hash ends in 0:

hash(5 * 21) = 1253e9373e...5e3600155e860

In Bitcoin, the Proof of Work algorithm is called Hashcash. And it’s not too different from our basic example above. It’s the algorithm that miners race to solve in order to create a new block. In general, the difficulty is determined by the number of characters searched for in a string. The miners are then rewarded for their solution by receiving a coin—in a transaction.

The network is able to easily verify their solution.

Implementing basic Proof of Work

Let’s implement a similar algorithm for our blockchain. Our rule will be similar to the example above:

Find a number p that when hashed with the previous block’s solution a hash with 4 leading 0s is produced.

To adjust the difficulty of the algorithm, we could modify the number of leading zeroes. But 4 is sufficient. You’ll find out that the addition of a single leading zero makes a mammoth difference to the time required to find a solution.

Our class is almost complete and we’re ready to begin interacting with it using HTTP requests.


Step 2: Our Blockchain as an API

We’re going to use the Python Flask Framework. It’s a micro-framework and it makes it easy to map endpoints to Python functions. This allows us talk to our blockchain over the web using HTTP requests.

We’ll create three methods:

  • /transactions/new to create a new transaction to a block
  • /mine to tell our server to mine a new block.
  • /chain to return the full Blockchain.

Setting up Flask

Our “server” will form a single node in our blockchain network. Let’s create some boilerplate code:

A brief explanation of what we’ve added above:

  • Line 15: Instantiates our Node. Read more about Flask here.
  • Line 18: Create a random name for our node.
  • Line 21: Instantiate our Blockchain class.
  • Line 24–26: Create the /mine endpoint, which is a GET request.
  • Line 28–30: Create the /transactions/new endpoint, which is a POSTrequest, since we’ll be sending data to it.
  • Line 32–38: Create the /chain endpoint, which returns the full Blockchain.
  • Line 40–41: Runs the server on port 5000.

The Transactions Endpoint

This is what the request for a transaction will look like. It’s what the user sends to the server:

{
 "sender": "my address",
 "recipient": "someone else's address",
 "amount": 5
}

Since we already have our class method for adding transactions to a block, the rest is easy. Let’s write the function for adding transactions:

A method for creating Transactions

The Mining Endpoint

Our mining endpoint is where the magic happens, and it’s easy. It has to do three things:

  1. Calculate the Proof of Work
  2. Reward the miner (us) by adding a transaction granting us 1 coin
  3. Forge the new Block by adding it to the chain

Note that the recipient of the mined block is the address of our node. And most of what we’ve done here is just interact with the methods on our Blockchain class. At this point, we’re done, and can start interacting with our blockchain.

Step 3: Interacting with our Blockchain

You can use plain old cURL or Postman to interact with our API over a network.

Fire up the server:

$ python blockchain.py
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Let’s try mining a block by making a GET request to http://localhost:5000/mine:

Using Postman to make a GET request

Let’s create a new transaction by making a POST request tohttp://localhost:5000/transactions/new with a body containing our transaction structure:

Using Postman to make a POST request

If you aren’t using Postman, then you can make the equivalent request using cURL:

$ curl -X POST -H "Content-Type: application/json" -d '{
 "sender": "d4ee26eee15148ee92c6cd394edd974e",
 "recipient": "someone-other-address",
 "amount": 5
}' "http://localhost:5000/transactions/new"

I restarted my server, and mined two blocks, to give 3 in total. Let’s inspect the full chain by requesting http://localhost:5000/chain:

{
  "chain": [
    {
      "index": 1,
      "previous_hash": 1,
      "proof": 100,
      "timestamp": 1506280650.770839,
      "transactions": []
    },
    {
      "index": 2,
      "previous_hash": "c099bc...bfb7",
      "proof": 35293,
      "timestamp": 1506280664.717925,
      "transactions": [
        {
          "amount": 1,
          "recipient": "8bbcb347e0634905b0cac7955bae152b",
          "sender": "0"
        }
      ]
    },
    {
      "index": 3,
      "previous_hash": "eff91a...10f2",
      "proof": 35089,
      "timestamp": 1506280666.1086972,
      "transactions": [
        {
          "amount": 1,
          "recipient": "8bbcb347e0634905b0cac7955bae152b",
          "sender": "0"
        }
      ]
    }
  ],
  "length": 3
}

Step 4: Consensus

This is very cool. We’ve got a basic Blockchain that accepts transactions and allows us to mine new Blocks. But the whole point of Blockchains is that they should be decentralized. And if they’re decentralized, how on earth do we ensure that they all reflect the same chain? This is called the problem of Consensus, and we’ll have to implement a Consensus Algorithm if we want more than one node in our network.

Registering new Nodes

Before we can implement a Consensus Algorithm, we need a way to let a node know about neighbouring nodes on the network. Each node on our network should keep a registry of other nodes on the network. Thus, we’ll need some more endpoints:

  1. /nodes/register to accept a list of new nodes in the form of URLs.
  2. /nodes/resolve to implement our Consensus Algorithm, which resolves any conflicts—to ensure a node has the correct chain.

We’ll need to modify our Blockchain’s constructor and provide a method for registering nodes:

A method for adding neighbouring nodes to our Network

Note that we’ve used a set() to hold the list of nodes. This is a cheap way of ensuring that the addition of new nodes is idempotent—meaning that no matter how many times we add a specific node, it appears exactly once.

Implementing the Consensus Algorithm

As mentioned, a conflict is when one node has a different chain to another node. To resolve this, we’ll make the rule that the longest valid chain is authoritative. In other words, the longest chain on the network is the de-factoone. Using this algorithm, we reach Consensus amongst the nodes in our network.

The first method valid_chain() is responsible for checking if a chain is valid by looping through each block and verifying both the hash and the proof.

resolve_conflicts() is a method which loops through all our neighbouring nodes, downloads their chains and verifies them using the above method. If a valid chain is found, whose length is greater than ours, we replace ours.

Let’s register the two endpoints to our API, one for adding neighbouring nodes and the another for resolving conflicts:

At this point you can grab a different machine if you like, and spin up different nodes on your network. Or spin up processes using different ports on the same machine. I spun up another node on my machine, on a different port, and registered it with my current node. Thus, I have two nodes: http://localhost:5000 and http://localhost:5001.

Registering a new Node

I then mined some new Blocks on node 2, to ensure the chain was longer. Afterward, I called GET /nodes/resolve on node 1, where the chain was replaced by the Consensus Algorithm:

Consensus Algorithm at Work

And that’s a wrap… Go get some friends together to help test out your Blockchain.


I hope that this has inspired you to create something new. I’m ecstatic about Cryptocurrencies because I believe that Blockchains will rapidly change the way we think about economies, governments and record-keeping.

Update: I’m planning on following up with a Part 2, where we’ll extend our Blockchain to have a Transaction Validation Mechanism as well as discuss some ways in which you can productionize your Blockchain.

If you enjoyed this guide, or have any suggestions or questions, let me know in the comments. And if you’ve spotted any errors, feel free to contribute to the code here!

No comments yet.

Leave a Reply