We produce a colossal amount of goods every year, yet sadly much of this ends up straight in landfill. Every time we buy a new item we leave a small footprint on the planet. It's estimated that in textile waste alone, 92 million tons are created globally every year! Apps like Gumtree, Wallapop and Depop are hugely popular and the second hand market valuation is huge, yet no blockchain based versions of these apps exist.

This is a shame, because Ethereum provides some particularly useful features for ensuring the successful completion of second hand purchases. Barrio leverages these to provide an escrow functionality within its smart contracts, as well as a reputational proof system and a tokenomics incentive system to allow people to exchange goods and services with confidence.

What it does

Barrio is a decentralized classified ads dApp and multi-purpose ecosystem where you can buy and sell pre-loved items, services, collectibles, antiques, rare items, NFTs, artwork and more! It allows users to list items and services for sale, and to make offers on them, securing their data in IPFS and rewarding them in Barrio tokens. Since the IPFS hash of the image data is stored in smart contracts, this can be used later for insurance claims, reselling or proof of provenance, making it compatible with a wide range of applications.

It provides two methods for listing goods and services: either a standard listing or an auction. The image data is saved in IPFS and application data is secured by 'gateway nodes' to provide metadata about users and listings.

In a standard listing the price is set, and after making an offer, buyers arrange with the seller to organize the exchange. During the exchange, when the buyer is in possession of the items they can "Confirm the purchase" in the app - which the seller can then verify before parting ways. Once a purchase is confirmed, any unsuccessful offers are refunded.

Listings are currently kept for three weeks - if nobody confirms a buy in this time, Chainlink Keepers are used to refund all buyers.

In an auction, the listed price is a minimum, and buyers are able to offer any amount above this. For the seller, there is an additional step since they must accept an offer before the buyer can confirm the purchase.

For any type of listing, the seller may provide the Ethereum address of a trusted third party, such as a local estate agent, auction house or possibly a local shop. They leave their item with the third party, who handles the rest of the transactions for them. Usually, the buyer will pick somebody a seller is also likely to trust, so that the goods can be exchanged easily. In the future, this could work via a decentralized IoT device, similar to an Amazon locker.

After a purchase is confirmed, the buyer and seller are now able to leave a review of each other. Over time, users increase their reputation by accumulating positive ratings, which facilitates new types of trade, such as exchange via post. With a high enough rating, a buyer may feel confident enough to confirm a purchase before receiving the goods. Ratings also allow people to up/down vote listing data, to secure the app from spam.

User data and application/listing metadata is stored in OrbitDB, and in the future, users will be able to earn rewards to spend in the app by securing the Barrio's data.

How I built it

The project uses Ethereum and Solidity for the Smart Contract logic, with Truffle for testing. I decided to use Infura (and web3) for deployment, as the API was nice and easy to use.

The listing data is stored in IPFS in two ways - the image data is stored via and the hash returned is then stored in the smart contracts. The metadata for the listings, and other application data is stored in OrbitDB.

Chainlink Keepers are used to ensure that after an auction or listing ends, that all funds are returned to unsuccessful buyers.

Barrio Architecture overview

Challenges I ran into

So many! I had a problem for a while that my contract was too large (bytesize) and I couldn't deploy it. Sometimes the error messages from the EVM are not that helpful :| so that took a while to figure out. I managed to "hack" it by removing a lot of inline comments, eventually I decided that the better solution was to rearchitect my dApp design and split some functionality into a new Ratings contract.

I also experimented with so much new tooling that it was overwhelming at first, and it was difficult to figure out how to fit everything together in a way that made sense for this project. I wanted to create something fully decentralized (so no central "server" backend, but instead using OrbitDB and filecoin in the browser), but I quickly realised this goal was perhaps a little too ambitious for the hackathon. Instead I brought in tools so that I can build out ideas later on, and focused on achieving the main functionality for now.

I also found that fetching the stored images from IPFS could be a little slow, depending on the health of the gateway. I had to do a few clever optimization tricks in the front-end app to try and ensure a smooth user experience.

Accomplishments that I'm proud of

This was my first ever hackathon, so I'm just really proud of finishing and doing everything myself! From the solidity smart contracts, backend and FE, to the design, copy, video and deployments, phew it was a lot! I experimented with a lot of new tools here - Chainlink, IPFS, Infura,, filecoin - even React was new, but I'm really glad I did it because it's given me a great overview of decentralized architecture. I've come away with more ideas than I started with, and that's a great thing!

What I learned

I learned a lot about solidity and smart contract design. I also learned a lot about Chainlink and the products offered and how they fit into smart contract design. Using OrbitDB was particularly interesting as it required a bit of a mindset change when architecting p2p databases. The way I've done it is certainly not optimal, but I learned a lot about the ideas of decentralised databases, and how data is partitioned differently.

What's next for Barrio: Decentralized classified ads

There is sooooo much I'd like to do/finish with this!

The home page of the website lists some features I'd really like to add to this project but ran out of time to do, this includes but is in no way limited to:

  • I'd really like Barrio to become a community and ecosystem, more than just a declassified ads website. I'd like to introduce some more complex tokenomics to incentivise securing the ecosystem's data, in exchange to credits to use on the site. I think this will require digging into filecoin internals a little more and linking this with a smart contract. Perhaps that can be my next hackathon project.
  • Improving error messages: many parts of the site currently fail for legitimate reasons (i.e. the smart contract reverts a request because it's being requested in the wrong state (i.e. confirming a bid in an auction before an offer is accepted), but these error messages from the EVM aren't yet communicated to the user. I have a modal that comes up when something fails, but I'd really like to leverage the error messages available from the EVM to display to the user.
  • I'd also like to build an encrypted messaging app on the site, for buyers and sellers to communicate.
  • I'd also like to show the listings location (since this data is already stored and available in the FE), as well as offering a search functionality.
  • To be useful to as wider audience as possible, I'd like to add a feature to pay in pegged USD currency.
  • I'd like to build a "defi" layer as part of the application, where people can offer collateral or insurance on purchases. This would create a more mature ecosystem with new layers of functionality built on top of just listings.
  • I'd also like to add support for "multiple purchases", i.e. when someone wants to list a service that can be bought multiple times (for instance, I might want to use the platform to sell English lessons, but I don't want to do this only once!).
  • There are a lot of data concerns that could be optimised here (sorting listings, not showing bought listings, deleting old data, improving the metadata to include things like item category (e.g. whether it's furniture, clothing, etc), which would also help with the following point:
  • I need to add filters and search functionality to allow people to search by location, category etc
  • Last thing, but if would be really easy to adapt this to support selling any other digital asset which can be stored in IPFS (so music, videos, software and games could also be listed alongside physical items, making it truly a multipurpose platform.

Built With

Share this project: