Our Articles

Crypto Fund Management

Cryptocurrency is a new asset class derived from nascent blockchain technology. Its phenomenal growth in recent years has attracted many investors who used to invest in traditional financial products to start investing in crypto assets. Reports have shown that there is a significant amount of capital flowing into the crypto market. This capital flow has created an increasing demand for new financial products that cater to the needs of the crypto market.

Indeed, cryptocurrencies are rapidly gaining traction with the general public. According to CoinMarketCap, the total market cap for all cryptocurrencies reached an amazing $739 billion in January 2018. Though the market cap dropped to a low $113 billion in December 2018 due to the bear market, it rebounded strongly in 2019 to a figure between $250 billion to $350 billion. Though much of this value has been generated by individual traders, it is also largely the result of large investment funds. These crypto fund management companies, which hold crypto assets worth as much as $1 billion or more, are the whales of the cryptocurrency community.

Generally, the trading of crypto assets is performed on exchanges. Most crypto investors keep and manage their crypto assets on exchanges, cold storage, mobile wallets, desktop wallets, hardware wallets, and more. The aforementioned complex management process that requires sophisticated skills makes it extremely difficult for individuals to manage a diverse crypto portfolio.

Fortunately, a dozen crypto fund management companies have emerged with products and services that could help ease the tedious investment process in crypto investment. One of the most popular ones is the use of index funds to automate the process of investing in crypto assets for individuals, using AI algorithms. Another crypto financial product on the rise is the crypto hedge fund which caters only to high net worth individuals.

Indeed, crypto investment tools and products such as crypto index funds, automated trading with rebalancing, and tracking are becoming ubiquitous. Crypto index funds provide an opportunity for investors to build their own portfolio or track an index and reap profits from this new and volatile asset class.

Despite the potential issues, it’s encouraging that crypto hedge funds seem to have performed reasonably well even during bear markets. And with the majority of crypto funds in the index now employing external auditors, custodian services and fund administrators, the industry is becoming less risky. Although the crypto fund industry is still very much in a nascent stage, crypto funds could present institutions and individuals with an attractive way to invest in this sector.

Let’s examine some index funds in the crypto market.

Bitwise 10 Private Index Fund

The Bitwise 10 Private Index Fund is the world’s first crypto asset index fund. It seeks to track the Bitwise 10 Large Cap Crypto Index (“Bitwise 10 Index”), which selects the 10 largest crypto assets based on criteria including 5-year diluted market capitalization, trade volume minimums, concentration limits, and compliance. The portfolio is rebalanced monthly. Assets are held in 100% cold storage, audited annually, and purchased across several liquidity providers to seek best execution. Bitwise actively evaluates network opportunities including hard forks, airdrops, emissions, staking rewards, super- and master-node rewards, and captures available benefits for fund investors where appropriate.

Bitwise is a crypto asset manager founded in 2017. The firm has a large software team, with backgrounds across Google, Facebook, Wealthfront, and military software security, which we believe is essential for navigating the space. Bitwise has been covered by CNBC, Forbes, Bloomberg, Barron’s, WSJ, Coindesk, and others, and is active in the crypto asset community

BITWISE 10 INDEX COMPONENTS

Bitcoin BTC77.8%
Ethereum ETH8.5% 
Ripple XRP6.0%
Bitcoin Cash BCH 2.4%
Stellar Lumens XLM0.6% 
Litecoin LTC 1.9%
EOS EOS1.4% 
Monero  XMR0.5%
Cardano ADA0.4%
DASH DASH 0.4%

Crypto20

Crypto20 claims to be the first tokenized index crypto index fund in the world. Their motto is autonomous ‘token-as-a-fund’.

In 2017, their team successfully pioneered the first tokenized crypto-only index fund, which used the seed funding to buy the underlying crypto assets. There are no broker fees, no exit fees, no minimum investment and full control over your assets. 

Crypto20 provides a way to track the performance of the crypto markets as a whole by holding a single crypto asset. They claimed that their index funds have consistently beaten the average managed fund since their inception. 

Learn more about Crypto20 from their whitepaper.

Alternatively, you can look into more accessible funds that don’t require heavy investment. Let’s take a look at the following funds:

Coinbase

The Coinbase Bundle offers a one-click purchase for the first five cryptocurrencies that were listed on Coinbase, which are weighted by market cap at the time of purchase.

  • Bitcoin — 76.59%
  • Ethereum — 15.84%
  • Litecoin — 3.94%
  • Bitcoin Cash — 3.11%
  • Ethereum Classic — 0.52%

This retail-aimed product allows users to invest as little as $25 in the basket of crypto assets.

Hodlbot

HodlBot is a customizable cryptocurrency trading bot that enables users to index the market, create custom portfolios, and automatically rebalance their cryptocurrency portfolios. 

HodlBot allows you to grow your portfolio like the world’s most sophisticated investors. They are making institutional portfolio management software available to everyone. Best of all, HodlBot is free forever for account values under $500. Otherwise, it’s $10/month with a 7-day free trial.

In short, crypto index funds are a fast-growing alternative financial product that is currently outperforming the stock markets and other traditional financial products. Though it is still riskier than traditional investments, it is worth venturing into this market to grow your capital. 

References

Blockchain-based Event Management and Ticketing Platform

The event management and ticketing industry is a huge market, particularly the event management software market. Markets Insider reported that the Event Management Software Market is projected to grow from USD 5.7 billion in 2019 to USD 11.4 billion by 2024, at a CAGR of 15% from 2019 to 2024.

However, despite the great potential of the event and ticketing industry, there are numerous problems and issues plaguing the current centralized event ticketing industry. The main issues include ticket counterfeiting, ticket scalpers, instant sell-outs and overpriced resale tickets on secondary markets (EventChain, 2017).

The good news is that the blockchain could fix the aforementioned issues.  A blockchain is a distributed digital ledger that can be used to record transactions and other data across a decentralized peer-to-peer network made up of a cluster of computing devices.

Using blockchain technology, every ticket sales can be publicly verified, and thus the authenticity of the ticket can be guaranteed. It is also able to prevent fraudulent sales and counterfeiting. It sets rules (using smart contracts) preventing secondary ticket websites from hoarding tickets and charging inflated prices for premium events. If the rules are broken, the fraudulent accounts are frozen and the tickets are made invalid.

In a nutshell, a blockchain-based event and ticketing system has the following benefits:

  • Elimination of ticket duplication and counterfeit tickets
  • Elimination of scalpers
  • Elimination of ticket touts and purchasing bots
  • Fully transparent ticketing aftermarket
  • Automatic refund at the time of cancelation

Use Cases

BitTicket

The Edinburgh-based Citizen Ticket is an event ticketing platform backed by blockchain technology that uses the cryptocurrency Ethereum Classic. In May 2017, they deployed the blockchain-based ticketing system BitTicket and delivered the first live event using blockchain technology.

BitTicket is a ticket delivery service that event organisers, venues, and artists can use to secure their tickets with blockchain technology. BitTicket provides users with one wallet QR code that holds all their BitTickets securely, no matter which ticketing provider they bought them from. They simply present it along with proof of ID to gain entry. Due to the security of BitTicket identity, ticket transfer to friends and family can be done easily and with assurance. BitTickets are immutable, transferable, and verifiable.

BitTicket guarantees the following:

  • Your purchased ticket is genuine
  • Inherent protection against industrial-scale ticket touts and ticket purchasing bots
  • Transfer your tickets securely and with ease between friends & family
  • Provides one wallet for all your tickets – no more individual tickets

GUTS

GUTS uses blockchain technology to create a transparent ticketing ecosystem where inflated secondary market prices and ticket fraud are eliminated. Their motto is simple, transparent and secure.

GUTS brings numerous benefits for different stakeholders:

  • Artist and Managers
    • A fair chance for all the fans to attend the show
    • Expand the fan base with exact data
    • Direct communication with your fans. Send them a message right before the show starts.
  • The Venue, Festival and Theatre Operators
    • No ticket fraud: fewer complaints and a stronger image
    • You know exactly who is present at any time (and who isn’t)
    • Automatic refund procedure at the time of cancelation or resale
    • Identification via mobile phones means shorter queues
  • Ticket Providers
    • Complete control of the tickets in both the primary and secondary market
    • Easy to integrate with existing ticketing solutions

LAVA

LAVA is a blockchain-based ticketing system that guarantees fair and secure smart tickets for music lovers. The system prevents ticket touting and fraud ruining festivals for music lovers.

The LAVA ecosystem has the following features:

  • 100% Safe
    • Using latest blockchain technology to eliminate ticket fraud
  • Smart Tickets
    • Smart tickets to stop the exploitation of festival tickets using a unique digital footprint
  • Lava Wallet – Eliminate printing completely by generating the ticket digitally and sending the digital ticket to the Lava wallet directly
  • No booking fee

PouchNATION

PouchNATION is an event management software system that uses the blockchain technology to good effect. PouchNATION is the first platform to implement blockchain and new digital currency across all verticals in event management. Its components comprise guest registration, cashless payment, access control, activity tracking, social engagement and detailed analytics reporting.

This innovative platform could overcome issues that the ticket industry is currently facing with managing events, attendance tracking apps, eliminating duplicate tickets, and validating registration at the door.

They have executed over 100 events including cashless events in Indonesia, Philippines, Vietnam, Malaysia, Thailand, and Myanmar.

EventChain

EventChain is a global Smart Ticketing blockchain project that will allow events worldwide to sell SmartTickets through a peer-to-peer network, solving the issues of the centralized event ticketing industry.

It implements the EventChain token network for event management to ensure faster transactions, indisputable ticket vouchers, transparency from event hosts and fully flexible and programmable SmartTickets. With the use of the EVC token, smart contract code, and the Ethereum blockchain, EventChain’s transaction network brings increased accountability, transparency, and security to event ticketing.

To fix the excessive ticket fees, EventChain is distributing EVC tokens, a digital ERC20 token created for buying, selling, and programming SmartTickets on the Ethereum distributed network. EventChain claims that their transaction fees are much lower and the transaction confirmation speed is near seconds.

Event Management and Ticketing Platform-A Conceptual Model

After examining the above use cases, I propose a conceptual model that utilises a similar concept to develop a blockchain-based event management and ticketing platform. Below is a simple conceptual model of the Event Management and Ticketing Platform:

The platform allows an event organizer to create an event and broadcast it to the website as well as a mobile wallet. The event should comprise details such as event title, date, time, venue, and a ticketing ordering button. The participant can then order tickets by paying  Token X. Once the organizer receives Token X, the e-ticket shall be automatically delivered to the participant’s mobile wallet. To enter the event venue, the organizer just needs to scan the e-ticket of the participant.

To build the platform, we need to build a smart contract layer on top of blockchain network to automate the buying and selling of event tickets. We shall use Solidity to write the contracts. There shall be at least three smart contracts -the ERC20 token contract(to generate Token X),  the event contract, and the ERC721 ticket contract. The event contract will need to link to the ticket contract as it needs to use the data in the ticket contract. The keyword to access the data in another contract is import. For example, we can create an event contract event.sol that imports the ticket contract ticket.sol, using the syntax as follows:

Pragma Solidity ^0.5.0
import "./ticket.sol"; 

The event.sol file shall create an event contract that specifies event details such as total tickets, collected funds, start time, etc. The code could be as follows:

Contract Event { 
 struct EventDetails {  
 uint256 ticketAmount; 
 uint256 SoldticketAmount; 
 uint256 CollectedFunds; 
 uint256 StartTime; 
  } 

The event contract shall also include a create event function, as follows:

function CreateEvent{
 uint256 _ticketAmount; 
 uint256 _Startime 
}

There are many more functions to be included in the smart contracts but I will not dwell further as this is not a technical paper.

References


Event Management and Ticketing Platform

The event management and ticketing industry is a huge market, particularly the event management software market. Markets Insider reported that the Event Management Software Market is projected to grow from USD 5.7 billion in 2019 to USD 11.4 billion by 2024, at a CAGR of 15% from 2019 to 2024.

However, despite the great potential of the event and ticketing industry, there are numerous problems and issues plaguing the current centralized event ticketing industry. The main issues include ticket counterfeiting, ticket scalpers, instant sell-outs and overpriced resale tickets on secondary markets (EventChain, 2017).

The good news is that the blockchain could fix the aforementioned issues.  A blockchain is a distributed digital ledger that can be used to record transactions and other data across a decentralized peer-to-peer network made up of a cluster of computing devices.

Using blockchain technology, every ticket sales can be publicly verified, and thus the authenticity of the ticket can be guaranteed. It is also able to prevent fraudulent sales and counterfeiting. It sets rules (using smart contracts) preventing secondary ticket websites from hoarding tickets and charging inflated prices for premium events. If the rules are broken, the fraudulent accounts are frozen and the tickets are made invalid.

In a nutshell, blockchain-based event and ticketing system has the following benefits:

  • Elimination of ticket duplication and counterfeit tickets
  • Elimination of scalpers
  • Elimination of ticket touts and purchasing bots
  • Fully transparent ticketing aftermarket
  • Automatic refund at the time of cancelation

Use Cases

BitTicket

The Edinburgh-based Citizen Ticket is an event ticketing platform backed by blockchain technology that uses the cryptocurrency Ethereum Classic. In May 2017, they deployed the blockchain-based ticketing system BitTicket and delivered the first live event using blockchain technology.

BitTicket is a ticket delivery service that event organisers, venues, and artists can use to secure their tickets with blockchain technology. BitTicket provides users with one wallet QR code that holds all their BitTickets securely, no matter which ticketing provider they bought them from. They simply present it along with proof of ID to gain entry. Due to the security of BitTicket identity, ticket transfer to friends and family can be done easily and with assurance. BitTickets are immutable, transferable, and verifiable.

BitTicket guarantees the following:

  • Your purchased ticket is genuine
  • Inherent protection against industrial-scale ticket touts and ticket purchasing bots
  • Transfer your tickets securely and with ease between friends & family
  • Provides one wallet for all your tickets – no more individual tickets

GUTS

GUTS uses blockchain technology to create a transparent ticketing ecosystem where inflated secondary market prices and ticket fraud are eliminated. Their motto is simple, transparent and secure.

GUTS brings numerous benefits for different stakeholders:

  • Artist and Managers
    • A fair chance for all the fans to attend the show
    • Expand the fan base with exact data
    • Direct communication with your fans. Send them a message right before the show starts.
  • The venue, Festival and Theatre Operators
    • No ticket fraud: fewer complaints and a stronger image
    • You know exactly who is present, anytime (and who isn’t)
    • Automatic refund procedure at the time of cancelation or resale
    • Identification via mobile phones means a shorter queue
  • Ticket Providers
    • Complete control on the tickets at both the primary and secondary market
    • Easy to integrate with existing ticketing solutions

LAVA

LAVA is a blockchain-based ticketing system that guarantees fair and secure smart tickets for music lovers. The system could prevent ticket touting and fraud ruining festivals for music lovers.

The LAVA ecosystem has the following features:

  • 100% Safe
    • Using latest blockchain technology to eliminate ticket fraud
  • Smart Tickets
    • Smart tickets to stop the exploitation of festival tickets using a unique digital footprint
  • Lava Wallet-Eliminate printing completely by generating the ticket digitally and sending the digital ticket to the Lava wallet directly.
  • No booking fee

PouchNATION

PouchNATION is an event management software system that uses the blockchain technology to good effect. PouchNATION is the first platform to implement blockchain and new digital currency across all verticals in event management. Its components comprise guest registration, cashless payment, access control, activity tracking, social engagement and detailed analytics reporting.

This innovative platform could overcome issues that the ticket industry is currently facing with managing events, attendance tracking apps, eliminating duplicate tickets, and validating registration at the door.

They have executed over 100 events including cashless events in Indonesia events in Indonesia, Philippines, Vietnam, Malaysia, Thailand, and Myanmar.

EventChain

EventChain is a global Smart Ticketing blockchain project that will allow events worldwide to sell SmartTickets through a peer-to-peer network, solving the issues of the centralized event ticketing industry.

It implements the EventChain token network for event management presents to ensure faster transactions, indisputable ticket vouchers, transparency from event hosts and fully flexible and programmable SmartTickets. With the use of the EVC token, smart contract code, and the Ethereum blockchain, EventChain’s transaction network brings increased accountability, transparency, and security to event ticketing.

To fix the excessive ticket fees, EventChain is distributing EVC tokens, a digital ERC20 token created for buying, selling, and programming SmartTickets on the Ethereum distributed network. EventChain claims that their transaction fees are much lower and the transaction confirmation speed is near seconds.

A Conceptualised Event Management and Ticketing Platform

After examining the above use cases, I propose that we can use a similar concept to develop blockchain-based event management and ticketing system for a decentralized platform. Below is a simple conceptual model of Event Management and Ticketing platform:

The platform allows an event organizer to create an event and broadcast it to the website as well as the Token X wallet. The event should comprise details such as event title, date, time, venue, and a ticketing ordering button. The participant can then order tickets by paying Token X. Once the organizer receives Token X, the e-ticket shall be automatically delivered to the participant’s mobile wallet. To enter the event venue, the organizer just needs to scan the e-ticket of the participant.

To build the platform, we need to build a smart contract layer on top of the platform to automate the buying and selling of event tickets. We shall use Solidity to write the contracts. There shall be at least two smart contracts – the event contract, and the ticket contract. The event contract will need to link to the ticket contract as it needs to use the data in the ticket contract. The keyword to access the data in another contract is import. For example, we can create an event contract event.sol that imports the ticket contract ticket.sol, using the syntax as follows:

Pragma Solidity ^0.5.0
import "./ticket.sol";

The event.sol file shall create an event contract that specifies event details such as total tickets, collected funds, start time, etc. The code could be as follows:

Contract Event { 
struct EventDetails { 
uint256 ticketAmount;
uint256 SoldticketAmount;
uint256 CollectedFunds;
uint256 StartTime;
 }

The event contract shall also include a create event function, as follows:

function CreateEvent{
uint256 _ticketAmount;
uint256 _Startime
}

There are many more functions to be included in the smart contracts but I will not dwell further as this is not a technical paper.

References

Developing a DAPP – KittyChain Shop

What is DApp?

DApp is an abbreviation for decentralized application.

A DApp has its backend code running on a decentralized peer-to-peer network. Contrast this with an app where the backend code is running on centralized servers.

A DApp can have frontend code and user interfaces written in any language that can make calls to its backend. Furthermore, its frontend can be hosted on decentralized storage such as Swarm or IPFS.

The Project Description

In this project, we shall use Ganache (https://truffleframework.com/ganache) to develop the KittyChain Shop DApp.

Ganache is a personal blockchain for Ethereum development you can use to deploy contracts, develop your applications, and run tests. It is available as both a desktop application as well as a command-line tool (formerly known as the TestRPC). Ganache is available for Windows, Mac, and Linux.

Truffle is a world-class development environment, testing framework and asset pipeline for blockchains using the Ethereum Virtual Machine (EVM), aiming to make life as a developer easier.

The KittyChain DApp is an adoption tracking system for a pet shop

Steps to build the Dapp

  1. Setting up the development environment
  2. Creating a Truffle project using a Truffle Box
  3. Writing the smart contract
  4. Compiling and migrating the smart contract
  5. Testing the smart contract
  6. Creating a user interface to interact with the smart contract
  7. Interacting with the dApp in a browser

Step 1  Setting up the development environment

Install the following:

  1. Node.js
  2. Git
  3. Truffle 

Having installed the aforementioned packages, we shall proceed to install Ganache. You can download Ganache by navigating to http://truffleframework.com/ganache and clicking the “Download” button.

Step 2  Creating a Truffle project using a Truffle Box

Truffle initializes in the current directory, so first create a directory in your development folder of choice and then move inside it.

mkdir pet-shop-tutorial

cd pet-shop-tutorial

Now you have created a Truffle Box called pet-shop, which includes the basic project structure as well as code for the user interface.

Next, use the truffle unbox command to unpack this Truffle Box.

truffle unbox pet-shop

The Output

Directory structure

The default Truffle directory structure contains the following folders and files:

  • contracts/: Contains the Solidity source files for our smart contracts. There is an important contract in here called Migrations.sol, which we’ll discuss later.
  • migrations/: Truffle uses a migration system to handle smart contract deployments. Migration is an additional special smart contract that keeps track of changes.
  • test/: Contains both JavaScript and Solidity tests for our smart contracts.
  • truffle.js: Truffle configuration file.

Step 3  Writing the smart contract

We’ll shall write the smart contract that will act as the back-end logic and storage.

Create a new file named Adoption.sol in the contracts/ directory. To save time, please download the file from:

http://javascript-tutor.net/blockchain/download/contracts/Adoption.sol

Adoption.sol

pragma solidity ^0.4.24;
 contract Adoption { 
    //array of 16 addresses, 20 bytes 
    address[16] public adopters; 
 // Adopting a pet 
    function adopt(uint petId) public returns (uint) { 
    require(petId >= 0 && petId <= 15); 
 adopters[petId] = msg.sender; 
   return petId; 
    }
 // Retrieving the adopters 
    function getAdopters() public view returns (address[16]) { 
       return adopters; 
    } 
 } 

Step 4 Compiling and migrating the smart contract

Now that we have the smart contract, we shall proceed to compile and migrate it.

Truffle has a built-in developer console known as Truffle Develop, which generates a development blockchain that we can use to test and deploy the smart contract. It also has the ability to run Truffle commands directly from the console. 

We need to compile the smart contract written in Solidity to bytecode for the Ethereum Virtual Machine (EVM) to execute. Think of it as translating our human-readable Solidity into something the EVM understands. In a terminal, make sure you are in the root of the directory that contains the DApp and type:

truffle compile

The output


Compiling ./contracts/Migrations.sol...
Compiling ./contracts/Adoption.sol...
Writing artifacts to ./build/contracts

Now that we’ve successfully compiled our contracts, it’s time to migrate them to the blockchain! Migration is the deployment script meant to alter the state of the application’s contracts, moving it from one state to the next. For the first migration, you might just be deploying new code, but over time, other migrations might move data around or replace a contract with a new one.

By the way, there is one JavaScript file already in the migrations/ directory: 1_initial_migration.js. This file handles deploying the Migrations.sol contract to observe subsequent smart contract migrations, and ensures we don’t double-migrate unchanged contracts in the future. Now let’s create our own migration script.

Create a new file named 2_deploy_contracts.js in the migrations/directory.

To save time, download the file from the following link:

http://javascript-tutor.net/blockchain/download/contracts/2_deploy_contracts.js

Before we can migrate our contract to the blockchain, we need to have a blockchain running. For this tutorial, we’re going to use Ganache, a personal blockchain for Ethereum development you can use to deploy contracts, develop applications, and run tests. If you haven’t already, download Ganache and double click the icon to launch the application. This will generate a blockchain running locally on port 7545.

Launch Ganache and you get the following output:

Now back in your VS Code terminal, enter the following command:

truffle migrate

You can see the migrations being executed in order, followed by the blockchain address of each deployed contract.

In Ganache, note that the state of the blockchain has changed. The blockchain now shows that the current block, previously 0, is now 4. In addition, while the first account originally had 100 ether, it is now lower at 99.94, due to the transaction costs of migration. 

Step 5 Testing the smart contract

Truffle is very flexible when it comes to smart contract testing, in that tests can be written either in JavaScript or Solidity. In this tutorial, we’ll be writing our tests in Solidity.

Create a new file named TestAdoption.sol in the test/ directory. To save time, download a copy of the file from the following link:

http://javascript-tutor.net/blockchain/download/test/TestAdoption.sol

We start the contract off with 3 imports:

  • Assert.sol: Gives us various assertions to use in our tests. In testing, an assertion checks for things like equality, inequality or emptiness to return a pass/fail from our test. Here’s a full list of the assertions included with Truffle.
  • DeployedAddresses.sol: When running tests, Truffle will deploy a fresh instance of the contract being tested to the blockchain. This smart contract gets the address of the deployed contract.
  • Adoption.sol: The smart contract we want to test.

To run the test, enter the following command

Truffle test

The output is as follows:

Step 6 Creating a user interface to interact with the smart contract

Now that we’ve created the smart contract, deployed it to our local test blockchain and confirmed we can interact with it via the console, it’s time to create a UI so that the user can interact with the  pet shop!

Included with the pet-shop Truffle Box is the code for the app’s frontend. It is the JavaScript file app.js within the src/ directory. You can download the app.js file from the following link:

http://javascript-tutor.net/blockchain/download/src/js/app.js

We need to instantiate web3 to create the UI. The global App object is to manage our application, load in the pets data in init() and then call the function initWeb3(). The web3 JavaScript library interacts with the Ethereum blockchain. It can retrieve user accounts, send transactions, interact with smart contracts, and more.

First, we check if there’s a web3 instance already active. (Ethereum browsers like Mist or Chrome with the MetaMask extension will inject their own web3 instances.) If an injected web3 instance is present, we get its provider and use it to create our web3 object.

If no injected web3 instance is present, we create our web3 object based on our local provider. (Here we fallback on http://localhost:7545 that points to Ganache.)

Instantiating the contract

We need to instantiate our smart contract so web3 knows where to find it and how it works. Truffle has a library to help with this called truffle-contract. It keeps information about the contract in sync with migrations, so you don’t need to change the contract’s deployed address manually.

First, we retrieve the artifact file for our smart contract. Artifacts are information about our contract such as its deployed address and Application Binary Interface (ABI). The ABI is a JavaScript object defining how to interact with the contract including its variables, functions and parameters.

Once we have the artifacts in our callback, we pass them to TruffleContract(). This creates an instance of the contract we can interact with. With our contract instantiated, we set its web3 provider using the App.web3Provider value we stored earlier when setting up web3.

We then call the app’s markAdopted() function in case any pets are already adopted from a previous visit. We’ve encapsulated this in a separate function since we’ll need to update the UI any time we make a change to the smart contract data.

Getting The Adopted Pets and Updating The UI

We shall access the deployed Adoption contract, then call getAdopters() on that instance.

We first declare the variable adoptionInstance outside of the smart contract calls so we can access the instance after initially retrieving it.

Using call() allows us to read data from the blockchain without having to send a full transaction, meaning we won’t have to spend any ether.

After calling getAdopters(), we then loop through all of them, checking to see if an address is stored for each pet. Since the array contains address types, Ethereum initializes the array with 16 empty addresses. This is why we check for an empty address string rather than null or other false value.

Once a petId with a corresponding address is found, we disable its adopt button and change the button text to “Success“, so the user gets some feedback. Any errors are logged to the console.

Handling the adopt() Function

We use web3 to get the user’s accounts. In the callback after an error check, we select the first account.

From there, we get the deployed contract as we did above and store the instance in adoptionInstance. This time though, we’re going to send a transaction instead of a call. Transactions require a “from” address and have an associated cost. This cost, paid in ether, is called gas. The gas cost is the fee for performing computation and/or storing data in a smart contract. We send the transaction by executing the adopt() function with both the pet’s ID and an object containing the account address, which we stored earlier in account.

The result of sending a transaction is the transaction object. If there are no errors, we proceed to call our markAdopted() function to sync the UI with our newly stored data.

Step 7 Interacting with the DApp in a browser

The easiest way to interact with our DApp in a browser is through MetaMask, a browser extension for both Chrome and Firefox.

Install MetaMask in your browser.

Once installed, you’ll see the MetaMask fox icon next to your address bar. Click the icon and you’ll see this screen appear:

At the initial MetaMask screen, click Import Existing DEN.

In the box marked Wallet Seed, enter the mnemonic that is displayed in Ganache.

Enter a password below that and click OK.

Now we need to connect MetaMask to the blockchain created by Ganache. Click the menu that shows “Main Network” and select Custom RPC.

In the box titled “New RPC URL” enter http://127.0.0.1:7545 and click Save.

The network name at the top will switch to say “Private Network”.

Each account created by Ganache is given 100 ether. You’ll notice it’s slightly less on the first account because some gas was used when the contract itself was deployed and when the tests were run. (Make sure you are running Ganache as well.)

Installing and configuring lite-server

We can now start a local web server and use the DApp. We’re using the lite-server library to serve our static files. This shipped with the pet-shop Truffle Box, but let’s take a look at how it works.

Let’s examine  bs-config.json 

{
 "port": 3000, 
  "server": { 
 "baseDir": ["./src", "./build/contracts"], 
 "open": false 
  }, 
 "browser": ["chrome"] 
 } 

This tells lite-server which files to include in our base directory. We add the ./src directory for our website files and ./build/contracts directory for the contract artifacts.

I added “browser”: [“chrome”]

So that the UI opens in the Chrome browser.

We’ve also added a dev command to the scripts object in the package.json file in the project’s root directory. The scripts object allows us to alias console commands to a single npm command. 

To launch the app, enter the command in the VS Code Console.

npm run dev

Kittychain Shop

Pet Shop UI

Metamask appears after clicking adopt.

Transactions are shown on Metamask.

And also on Ganache.

References

Blockchain-Based P2P Lending – The Qidax Model

Traditional P2P lending models are facing many issues. For example, the cost of onboarding customers remains high, so investors are wary of this kind of investment model. Besides that, this area is heavily regulated by the securities commission in most countries. While a handful of P2P companies have been approved to operate their businesses, many more P2P operators who failed to obtain a license are facing the nightmare of shutting down

Traditional P2P lending cannot allow borrowers and investors to directly match financing but rather needs to be handled as a credit intermediary through the P2P lending platform. The financing cost is increased because of the need to pay the agency fee. Other issues include the limited scalability of P2P lending services on an international scale. This is due to the aforementioned problems of loan repayment guarantees, as well as to regulatory issues (rules and regulations vary from country to country). There is also work to be done on accelerating the process of granting loans and so on.

Although P2P lending platforms are supposed to be operating in a decentralized manner, they are still largely operating in a centralized model. Data is usually stored and maintained on a central database, which might lead to human errors and manipulation of data. 

On the contrary, data stored on a blockchain are stored on the decentralised and distributed network, where every stakeholder has access to a copy of the same ledger. Furthermore, data on the blockchain is immutable, so no party can alter and manipulate the stored data. These characteristics of the blockchain will greatly enhance data security, increase transparency and instill trust amongst stakeholders. Therefore, blockchain is the perfect solution to solve the woes of current P2P lending models. Indeed, a dozen companies have started to deploy blockchain-based P2P lending platforms.

Blockchain-based P2P businesses are broadly divided into two models, the hybrid model and the pure cryptocurrency model. The hybrid model involves using cryptocurrency and fiat money while the pure cryptocurrency model uses only cryptocurrencies.

The Hybrid P2P Lending Model

This model uses a combination of fiat currency and cryptocurrency to provide P2P lending services. Let us examine a few companies that implement this model.

1. SALT

SALT (Secure Automated Lending Technology) is a leader in the blockchain-based P2P lending industry. SALT’s model allows borrowers to use their crypto assets as collateral to secure loans from an extensive network of lenders on the platform. It means SALT does not bother to check the credit score of borrowers but grant eligibility based on the amount of crypto assets they are willing to put up as collateral. The main advantage for SALT borrowers is the ability to borrow fiat money against the security of their crypto assets, which is considered more practical to ordinary people than the pure cryptocurrency lending model. 

To sign up as a member of SALT, a borrower needs to purchase SALT tokens, the cryptocurrency of the SALT platform. SALT is minted using an ERC20 smart contract. After signing up, borrowers have to deposit a certain amount of crypto assets (cryptocurrency) as collateral into the platform’s unique, multi-signature wallet address created by SALT’s Secure Automated Lending Technology. After the terms of the loan are agreed and approved, the lender will make a deposit in fiat money into the borrower’s bank account. The borrower will be obligated to make repayments in fiat money or stable coins (currently accepting USDC, TUSD, and PAX) on a regular basis before the 15th of the month. In the event of a default, his or her crypto assets will be transferred to the lender. 

In order for an asset to be qualified as collateral on the SALT Platform, it must meet certain eligibility requirements. First and foremost, it must be a blockchain asset. This means that the ownership of the asset must be recorded on a public or permission blockchain. Digital assets will be onboarded based off community demand.

Examples of the current eligible collateral include Bitcoin (BTC), Bitcoin Cash (BCH), Ether (ETH), Litecoin (LTE), Dogecoin (DOGE), Dash (DASH), TruUSD (TUSD), USD Coin (USDC), Paxos Standard Token (PAX), and PAX Gold (PXG).

2. Nexo

The Nexo P2P model is somewhat similar to the SALT model. It also possesses a cryptocurrency known as the Nexo. According to the Nexo website, the NEXO Token is the world’s first US SEC-compliant asset-backed token and is backed by the underlying assets of Nexo’s loan portfolio. It can be used for discounted interest rates and loan repayments, as well as collateral. One incentive for holding the NEXO token is that it pays dividends to holders. Thirty percent of the profits generated from Nexo loans go to a dividend pool that is then distributed to NEXO holders. Currently, dividend payments are being made in Ethereum (ETH), but there’s a good chance that this will expand to other cryptocurrencies in the future.

The loan approval process is fully automated. A credit line becomes instantly available to the borrower once the application is approved and there is no credit check. The borrower can spend money instantly with a card or withdraw money to a bank account. Spending on the credit line will incur an APR from 5.9% of what the borrower uses. Some advantages of NEXO compared to SALT is there is no minimum repayment, no hidden fees, and the interest is debited from the available limit. Besides that, the borrower can make repayments at any time. On top of that, the Nexo website states that it is the only insured account that lets you borrow instantly in 45+ fiat currencies and earn daily interest on your idle assets. Furthermore, NEXO makes its loans available worldwide. Anyone who holds cryptocurrency can take advantage of a Nexo loan. And since the loans are fully collateralized there’s no need for borrowers to worry about credit history or approvals.

Though the use cases for Nexo loans will be somewhat limited since they’re collateral-backed, the use of cryptocurrencies as collateral makes for an attractive alternative for those who hold cryptocurrencies and don’t want to sell yet and give up future gains, but still need fiat currency for immediate use.

At the moment, more than twenty cryptocurrencies including BTC, ETH, NEXO, XRP, TRON and more can be accepted as the collateral. Any loans taken can be repaid using cryptocurrency, fiat currency, or the Nexo token. They have made it as easy as possible to repay any loans. In contrast, SALT only accepts loan repayment in fiat currency, which is an inconvenience for the borrowers.

Pure Cryptocurrency P2P Lending Model

1. ETHlend

ETHlend is a decentralized cryptocurrency credit platform and the world’s first crypto lending marketplace. Unlike SALT and Nexo, it operates exclusively through Ethereum smart contracts. ETHlend also has a token known as the LEND token. It is the native ERC20 token of the ETHLend platform. Its token can be stored in any Ethereum wallet in a similar way as other ERC20 tokens.

The lending process at ETHlend is quite simple. When creating a smart contract, ETHLend requires borrowers to send ERC-20 tokens as collateral for ETH loans in the event of a borrower’s default. Currently ETH, BTC, LEND and more than 150 ERC20 tokens are accepted as collateral. There is no limit in the loan value, as the amount you can borrow depends on the value of your collateral. Borrowers can borrow up to 50% of their collateral value and up to 55% if LEND is used as collateral. This means the borrower needs to send to the smart contract 200% of the value of the loan in crypto assets. To become a lender, you will need to register on the platform and send to your in-app wallet some Ether and any of the currencies accepted in order to fund a loan or create a loan offer. The accepted currencies are ETH, LEND, DAI and TUSD. This also means borrowers will receive the aforementioned cryptocurrencies as loans.

The borrower needs to repay the loan in accordance with the contract, plus interest on the loan, and send them to a smart contract. The lender receives their ETH and interest from the smart contract, and the pledged tokens are unlocked and sent back to the borrower. In the event that the borrower cannot repay the loan, the lender will get the payments plus a liquidation fee from the collateral.

2. Elix

Elix is an Ethereum-based platform for lending, crowdfunding, and payments. The Elix team primarily focused on mobile platforms and usability in order to attract as large a user base as possible from the start. I will not discuss the payment and crowdfunding component of this platform, but rather concentrate only on its P2P lending component.

The uniqueness of this system lies in the fact that Elix offers a peer-to-peer lending program based on mutual incentives for the lender and the borrower. In Elix, both the lender and the borrower are incentivized by the system to meet the terms of the loan. When applying for a loan, participants can choose a mining period in order to receive system rewards in the form of a new token, “Token P”.

If the borrower pays the loan on time, the reward is divided between the lender receiving 65% and the borrower who receives 35%. If the borrower has late payments, the lender receives 100% of this fee. Token P will have a fixed maximum supply that the team expects to achieve in only a few decades.

The Qidax P2P Lending Model

After reviewing the aforementioned P2P lending models, I think the best model that suits a blockchain-based P2P lending conceptual model is the Nexo model. As it is a hybrid of the fiat and cryptocurrency model, this platform needs to work with a licensed P2P operator. I propose the following model:

Using a combination of BTC, ETH, USDT, and QP as collateral

The proposed P2P lending platform will accept BTC, ETH , USDT and Token X (the hypothetical cryptocurrency) as collateral. Any loans taken can be repaid using fiat currency, BTC, ETH , USDT and QP with a certain interest. Loans given to borrowers should be fiat currency. The crypto assets should be stored in a secure wallet. In the event of default, the crypto assets (USDT, ETH, BTC, and QP) will be transferred to the lender.

The loan approval process should be fully automated with no credit checks. The credit line should become instantly available to the borrower once the application is approved. Repayment should be flexible too. I propose that we use a wallet for borrowers to access the credit line offered by the P2P Lending platform and receive the funds once the loan is approved. Besides that, the borrower can repay the loan using the same wallet. Lenders can also access potential borrowers’ information using the wallet and deposit fiat money to be used as loans. It means we need to integrate the wallet to the P2P lending platform via an API.

I propose that 30% of the profit generated from P2P lending to be deposited into a dividend pool and distributed to QP holders. This way it incentivizes people to buy and hold QP.

References