/freedomDividend

Primary LanguageJavaScriptMIT LicenseMIT

Universal Basic Income Opt-In on Hyperledger Fabric

Andrew Yang, a 2020 presidential candidate in the U.S., is arguably the only technologist to ever join the race.

Yang predicts that there will be massive worker displacement due to technological automation in the next five years. His solution to the worker displacement problem and the core proposal of his presidential campaign is enrolling every U.S. citizen in the Universal Basic Income program, which he calls the Freedom Dividend.

Since there is money distribution involved and Andrew Yang's entire career being in technology, it makes for a fun thought experiment to imagine what the tech infrastructure could look like.

The the very basic framework proposed here is a chaincode on Hyperledger Fabric.

Each of the 50 states can run organizations and peers that join a channel.

Each of the organizations and peers can have an app that lets the U.S. citizens submit their opt-in agreement to the Freedom Dividend based on their Social Security number as their identifier. Once opted in, Social Security number holders can also opt out of the Freedom Dividend program and have their Social Security number removed from the world state.

Those that have opted in, can be queried from the world state to have their monthly distribution of the Universal Basic Income.

Prerequisites

This tutorial uses:

Note that for this tutorial, I am using Visual Studio Code version 1.38.1 as later versions have issues with the IBM Blockchain Platform extension.

The chaincode aka freedomDividendContract

Create the chaincode

  1. Start your Visual Studio Code the IBM Blockchain Platform extension installed.
  2. On the left pane, click the square IBM Blockchain Platform icon.
  3. Click Smart Contracts > Create New Project.
  4. Select Default Contract. Select JavaScript. Type in a name for your chaincode. For this tutorial, it's freedomDividendContract.
  5. Choose a directory to save your project to. In the directory, all the necessary chaincode files will be generated.
  6. Your main file is the contract in the ./lib/ directory. For this tutorial, it's freedomDividendContract.js. Do check out the code, as it's commented.
  7. Make sure your index.js file has the correct parameters relative to the contract. See index.js.
  8. Make sure you have the correct name and chaincode version in package.json. See package.json.

Package the chaincode

Make sure you have fabric-shim installed in your chaincode project directory:

npm i fabric-shim

Click Smart Contracts > Package Open Project.

Start the local network

Under Fabric Environments, click Local Fabric.

Starting the network will take a few minutes.

Once the network is started, connect to the network:

  1. Under Fabric Gateways, click Local Fabric. Select admin.

Install and instantiate the chaincode

Install:

  1. Under Fabric Environments, click Smart Contracts > Installed > Install.
  2. Select your packaged chaincode.

Instantiate:

  1. Click Instantiated > Instantiate.
  2. Select your installed chaincode.
  3. Leave the optional blank and hit Enter.
  4. Click No for the private data collection file.
  5. Select the default endorsement policy.

Instantiating the chaincode will take a few minutes.

Interact with the chaincode

Under Fabric Gateways, click Channels > mychannel > freedomDividendContract.

This will expand the three options to interact with your chaincode:

  • optIn — the arguments are ssnId, optedIn. For example, "123-45-6789", "opt in". This will submit the transaction with the provided Social Security number and update the world state.
  • optOut - the argument is ssnId. For example, "123-45-6789". If you have previously opted in with a Social Security number, this will submit the transaction and remove the Social Security number from the world state, effectively opting this number out.
  • querySSN — the argument is ssnId. If you have previously opted in with a Social Security number, this will query the world state and return a message that this number is opted in.

To interact with each of the options, right-click on it and select Submit Transaction.

Releases

If you want to just play around with a packaged chaincode, check Releases.