How Blockchain can Transform the Pet Industry

Securing pet ownership with a simple DApp

Samantha Ouyang
9 min readSep 2, 2021

--

When the world went into lockdown back in March 2020 as a result of the COVID-19 pandemic, we saw an unmatched level of panic buying. Customers spent hours in long lines needlessly stocking up on toilet paper, hand sanitizer, and canned beans. But while there was a surge in demand for groceries, there was something else that — perhaps more surprisingly and on a more positive note — also had a big boom in sales.

Animal adoptions have soared over the pandemic. The most popular of course: dogs. People rushed to adopt pets, so much so that shelters almost emptied. Private breeders, non-profit rescues, shelters, and pet stores all reported more consumer demand than there were dogs to fill it, with dozens of applications and waiting lists well into the new year. People were desperate to fill the voids in their lives, being stuck working from home, having to give children something to do, or trying to combat feelings of loneliness. As a result, having a new canine companion has brightened up the lives of thousands of families during some dreary times.

“Within my circle of friends, there are at least five people who have gotten a puppy.” — Tess Karaskevicus, a schoolteacher from Springfield, Virginia.

An increase in interest of owning a pet is not entirely new though. Over the last 30 years, pet ownership has gone from 56% to 68% of all American households. With millennials and Gen Z’s turning into adults, they’ve come to embrace the pet-owning lifestyle much more than with past generations, now buying pets for themselves while they move out and start their own families.

Problems with the Pet Industry

While everything seems like a happy ending, the pet industry is far from being all sunshine and rainbows. With the growing demand in recent years, cases of pet theft have been increasing in frequency. In fact, 2 million dogs are stolen each year, by criminals who simply see a dog as a way to make a quick buck by reselling it on the black market. Even if you’re lucky enough to find your dog again after going through the whole ordeal of contacting the police and putting up flyers, you still have to be able to prove ownership of your dog.

Dognapping gangs target women walking pets alone to keep up with demand as pedigree pups fetch £3,500 on black market.

What’s more, the pet industry is extremely fragmented and disconnected, lacking in transparency, and lags behind other industries technologically. For one, shelters are still not required to report the number of pets that they take in, adopt out, or euthanize. A ton of paperwork is involved as well, yet documents are still largely stored as physical copies. Even worse are the issue of puppy mills: commercial, high-volume dog breeding facilities that churn out puppies for profit, ignoring their health and needs. The puppies are taken from their mothers at a young age, packed into crates, and then trucked or flown to pet stores, often without adequate food, water, or ventilation.

Not much monitoring is currently in place — in fact, it’s pretty easy to get around local laws regarding breeding, not to mention that different states across the U.S. have different requirements and restrictions. There’s a growing trend of pets being sold via classified websites such as Craigslist or Kijiji, and since anyone can post an ad and sell something on there, callous breeders can operate in plain sight without consequences or suspicion. An industry like this that lacks robust systems opens the door for criminal activity, with breeders who may not provide healthy, fully-checked, and certified animals who may be sick or even abused.

Putting Pets on the Blockchain

In order to combat this issue, there has to be a fundamental change to the operations of the entire industry. Records of activity have to be taken at every point in the system, from when the pups are born, to when they’re vaccinated, transported, sold, and sold again, all the while ensuring that everything is protected from fraud.

One potential solution that can tackle some of the many different problems concerning the pet industry is blockchain technology. Put simply, blockchain is an immutable, digital ledger that allows data to be stored and shared globally across thousands of computers in the network.

There are three key features of blockchain that allow it to address the issue at hand:

  1. Immutability
  2. Decentralization
  3. Transparency

Immutability

The data stored on a blockchain is immutable, meaning it cannot be changed or altered. Once information is added, it is timestamped and stays there forever. If someone were to try and alter the information, it would invalidate all data added afterwards, making it clearly visible to everyone in the network that there is malicious intent at play. With that being said, if something has to be changed, the only way to do so would be to add the new piece of information on top of the old one, keeping a complete history of all data.

This allows blockchain to be a permanent, traceable, and undisputable record of tracking pet ownership. No one can effectively claim that a pet is theirs by making a shady transfer so that the pet is held under their own name, since blockchain is designed to be tamper-proof.

If block 4 is altered, all subsequent blocks up to and including block 9 will be invalidated. Source: ToughNickel

Decentralization

Blockchain is a decentralized database, meaning that there is no central authority governing the network. Rather, each computer in the network stores its own copy of the data, and they all work together to maintain its security.

The problem with a centralized network is that it has a single point of failure. If all documents for an animal shelter were stored on paper and held in that one location, they would all be vulnerable to disaster. With blockchain however, it would require multiple points of failure to make the system vulnerable — 51% of the network to be exact. In other words, you would need to have control of the majority of the network to rewrite the truth. Otherwise, the system would simply recognize the anomaly across all nodes and disregard that copy. In terms of the pet industry, this protects all of the documents against a potentially malicious player in the network.

An illustrated comparison of centralization and decentralization. Source: Capco

Transparency

Blockchains are transparent, meaning anyone with a computer can view the full record of all transactions. With all eyes watching, this means that it’s impossible to hide any activity (although you can hide information through encryption). As for the pet industry, the blockchain acts as the source of truth, since all others in the network can see for themselves and validate whether you have ownership of a pet or where the animal was sourced from.

Changing the Pet Industry

Bringing blockchain to the pet industry, we would be able to patch a number of holes in the pipeline that are opening the door to criminal activity by being able to:

  • Verify a dog’s original source, so we know whether it’s from a puppy mill or professional breeder
  • Prove ownership of a pet with each transaction acting as a “certificate”
  • Store information regarding previous owners and adopters
  • Associate each pet with a unique address
  • Digitize documents and records
  • Provide an effective management system for shelters or adoption centres

I built a simple proof-of-concept decentralized application (DApp) on Ethereum that allows for adopting pets and transferring ownership, securing the transaction and making the pet industry more transparent. Check it out below!

How I Made It

The backend of the DApp is controlled by a smart contract written in Solidity that associates an Ethereum address with a pet to be adopted. A smart contract is a self-executing computer program that runs on the blockchain, following the terms of the agreement that are coded into it.

To perform certain actions, we’ll have to pay gas — fees in Ethereum. This includes migrating contracts to the blockchain, deploying contracts, and adopting pets. No fees are required for simply viewing the pets or fetching the adopters.

The frontend was created with HTML, CSS, and JavaScript, and allows us to interact with the smart contract by instantiating Web3, which can fetch a contract artifact file containing the contract address and ABI.

Toolkit for this Project

  • Truffle → A world-class development environment, testing framework and asset pipeline for blockchains using the Ethereum Virtual Machine (EVM).
  • Ganache → A personal blockchain for Ethereum development you can use to deploy contracts, develop applications, and run tests.
  • MetaMask → A browser extension crypto wallet to manage your digital assets and make payments.
  • Injected Web3 environment → A Web3 instance is injected by MetaMask to initialize the application and allow us to interact with the contract via a web interface.
  • Visual Studio Code → A free source-code editor, used to create the frontend application.

Smart Contract Code

To begin, we’ll have to specify our compiler version and create the contract.

pragma solidity ^0.8.7;contract Adoption {

Next, we’ll define a variable to hold an array of Ethereum addresses. Every account and smart contract on Ethereum has an address that it uses to send and receive transactions.

address[16] public adopters; //define an array of length 16

We then create our first function, which allows users to make adoption requests. We check the value of the ID specified to ensure that it’s within the range of what is offered at the Animal Adoption Centre, then assign that respective slot in the adopters array to the address that called the function, or in our case, the individual that made the adoption request. Lastly, the function returns the pet ID as confirmation.

// Adopting a petfunction adopt(uint petId) public returns (uint) {    require(petId >= 0 && petId <= 15); //check that petID is in range of array    adopters[petId] = msg.sender; //add address that made the call to adopters array    return petId; //return petID provided as confirmation}

Our second function will simply return the entire adopters array, in order to have our user interface easily update all pet adoption statuses at once.

// Retrieving the adoptersfunction getAdopters() public view returns (address[16] memory) { //function to return the entire array    return adopters;}

Compilation and Migration

After writing the above contract and a separate Migrations contract (not shown), the next steps are to compile and migrate the main Adoption contract. While I won’t go into the details much, this essentially allows us to go from code to blockchain.

Since Solidity is a compiled language, we need to compile our code into bytecode for the EVM to understand and execute. Artifact files will also be automatically built during compilation, containing the contract address and ABI. Then, making sure our blockchain on Ganache is up and running, we migrate our contract to the blockchain. A migration is a deployment script meant to alter the state of your contracts. Note that the migration will require gas.

A Better Future for Our Animal Companions

By implementing blockchain in the area of pet adoption, we’ll enable tighter restrictions and more effective monitoring in an opaque industry that has fallen far behind with technology. While it certainly will not be an easy task, having to overcome barriers such as the radical departure from current manual processes or implementation costs, it offers a promising possibility for the future given collective dedication from the government and shelters.

Source: PetFinder

Our pets look to us to protect them, and with pet ownership becoming more ubiquitous, it’s a worthwhile investment to leverage the tools we have available to create better care and treatment for all pets.

If you enjoyed reading this article or learned something new, be sure to drop a follow on Medium and connect with me on LinkedIn! Also, if you’d like to keep up with the projects I’m working on, feel free to subscribe to my monthly newsletter. Thanks for reading!

--

--

Samantha Ouyang

Passionate about creating impact with emerging tech. Current obsessions include blockchain, empowering women in STEM, chemistry, and sustainable materials.