Inspiration and what it does

Nowadays, it is a sad reality that many crypto users have problems bankarizing their profits from cryptos. Even with the increasing awareness about the benefits of cryptos to the world, the strict regulations and lack of knowledge make it almost impossible to do it in many places. And in the places where it is possible, usually, the intermediaries take a great slice of the profit from the user. This leads to a limitation of the purchasing power of cryptocurrency users for high-cost goods and services.

Kartek was born because we have faced those kinds of problems and we were looking for a solution. There was nothing, so we built it (from scratch) with this MVP as a starting point. Kartek is a NFT marketplace for real cars.But, why to use a NFT instead of doing just a simple transfer transaction? Why increase the complexity of the system? The reason is because NFTs are not only memes or monkey collections, they are powerful tools which are undervalued by the users. Just because not many have taken the trouble to build around them. In the future a NFT might represent the ownership of a car or a house, however, with the current regulation this is out of reach for us, but this MVP could be a starting point.

In Kartek the car dealer creates the NFT based on real cars. So the NFT will represent the car, but it also provides other benefits attached to it. For example, the owner of the NFT has some reloadable detailing sessions for the car. Once he has finished them, he can get more and they will be loaded into the NFT, in the same way, any other parameters can be added to the NFT and use it like a customer fidelity card for example.

Moreover, the NFT gives the option to the user to transfer it to another wallet. It allows them to make a really nice gift if they wish for now, but one day might be enough as a proof of ownership saving time on paperwork. To claim the ownership of the car we only require that the person that shows in the dealership can sign a message with the account where the NFT is.

The vital reason for choosing the NFTs in the first place was the traceability. NFTs leave a more clean path than a simple transfer transaction. This is really important for us, because due to the reluctance of the traditional economic system, in order to bankarize the profits from car sales we need to provide really clear information about the whole process. As long as the cryptocurrency is from a clean source the user won’t have any problem. But, in the cases when the source of cryptos is not clear or it’s blacklisted, we keep the right to make a refund to the buyer. All of this is handled with the smart contract. The decision to base the marketplace in car sales was motivated by the fact that cars are an expensive and common good, and our broad experience importing and selling cars. So, we thought that would be easier to make as a bridge to crypto users to buy the car they wish.

How we built it

The platform is divided in two parts, the content management system (CMS) for the car dealers and the marketplace page for the customers.

Firstly, the content management system’s backend is written in Flask using a MySQL database for storing all relevant information which can’t be stored on chain for many reasons, being privacy the most important one, like cars brands, platform users and customers information for invoices. It is connected with the smart contracts with web3.py library. It has some event listeners running as parallel processes to handle the events emitted by the contracts, like for example, when there is a purchase, a refund or a reservation of a car.

The dashboard of the CMS is made with VueJS connecting to the smart contracts with ethersjs. It has a private section where we, as administrators of the platform, can add the car brands, models, extra equipment descriptions and all the static information which can be reused by the car dealers to create the ads later on. The public section is where any car dealer can manage their profile. They can easily create their ads in a few clicks, including the creation of the car's NFT, modify their ads (add pictures, descriptions…), invoices, providers and everything they need. As a MVP this section is restricted to just one dealer but it will be open to any car dealer which wants to use it once we fetch some interest in the platform.

Secondly, the marketplace page for the customers is made with vueJS and ethers. Kartek allows both crypto and FIAT payments for now, so we designed it following a more traditional aesthetic looking for balance for both types of customers. Most of the data for the marketplace is fetched from the previously described backend as we tried not to abuse data fetching from the blockchain and keep low complexity in the frontend. Moreover, we implemented a read-only fantom api node endpoint, which can handle all our workload with nice performance, while the transactions are submitted via the web3 injected client from the customer wallet (Metamask for now).

The smart contracts of the platform are written in Vyper, a less popular language than Solidity, which reduces the vulnerabilities due to its simplicity. Kartek has three main contracts: CarCollection, which is an ERC721 standard with some extra logic for our case. PriceOracles, which returns the amounts of tokens needed to cover a specific price in euros according to Chainlink oracles. Exchanger, which handles the swaps with the data provided by the 1inch api and forwards the returned balances to the CarCollection contract for later claiming of funds by the car dealer.

Challenges we ran into

When we started designing the platform, our main concern was how crypto volatility could affect the payment process and we assumed this would trouble any car dealer using the platform. Thus, the main challenge became the main purpose: to receive payments in stablecoins with as little friction as possible for the customer. With this objective in mind, we integrated 1inch directly in the smart contracts. It was challenging because 1inch and other DEX aggregators are not really made with this kind of integration in mind, so it required us to add quite a lot of logic to our backend and frontend. The first problem was that 1inch doesn't provide a way to calculate exact input for desired output so we had to make an estimation and call repetitively to their quote api. Still like that, we were forced to play with the slippage and send back change to the customer in the output coin “USDC” when the received output is more than the needed.

The next challenge was that dex aggregators are not completely trustless. We couldn’t blindly believe the data that their api says and send it to our contract. For that reason, we add a double check in our backend to ensure that the data returned by 1inch api is correct and that it meets our requirements. This method helps to prevent the customer from overspending their tokens and avoid any unexpected behavior from the platform.

Regarding the use of vyper to write the contracts, at first we had some hard time due to the little documentation available, but after a while everything was simpler than expected.

Finally, we had some difficulties with testing the contracts since 1inch or other dex aggregators don’t have a testnet version. We solved it by using local forks of the main chain. However, market conditions can change so quickly that sometimes transactions failed due to the different state in the local fork and the real chain (from which 1inch api takes data), even when only a few seconds have passed.

We managed to overcome all these challenges to build an easy to use platform that allows sellers to receive payments in stable currency, without requiring any knowledge or extra work from the customer to swap other tokens by themselves.

Accomplishments that we're proud of

It works.

What we learned

For this project we challenged ourselves to learn Vyper and along the path of writing the smart contracts we learnt quite a lot about dex aggregators. Besides, we mainly improve our previous knowledge and learnt a lot of minor things as with any project that you start almost from scratch.

What's next for Kartek

The goal of Kartek’s MVP is to publicize the project and get a user base. Once achieved, the next stage of the project is to rebuild the marketplace using Nuxt3 or Qwik frameworks, to improve the user experience, SEO and performance of the site. Then, we will add some minor features to the smart contracts, such as allowing an initial prepayment of a car on demand using the same system. And finally we plan to open the marketplace to other dealers, and if the users demand it, to other products. Even if the technology in this project is nothing disruptive, we think that this kind of platforms can help to bring cryptocurrencies closer to the real world.

Built With

Share this project:

Updates