Skip to main content
Articles

CrossApp: From CeFi To DeFi

By August 19, 2024No Comments

Turning challenges into opportunities is what we do every day.

Proactivity brings Innovation

In early November 2021, Crossjoin released a partnership with a nearby restaurant to provide high quality food with a 50% discount for employees (a.k.a, Crossers). The high adherence to this benefit created a bottleneck on a single Crosser who had to collect restaurant receipts from other Crossers and insert the information in a spreadsheet to settle how much Crossjoin had to pay that day to the restaurant. When I heard about this problem, the first thing that came to my mind was “Blockchain”.

On December 3rd, 2021, my interest in distributed systems led me to write an email to the CEO with a proposal to solve the problem by creating a payment system over a blockchain. I proceeded to inquire other Crossers about this idea, and this was when I met one colleague who had a similar idea. At the time, I had more free time than him because I was waiting for a project to begin, so in the beginning, I had to step in and push this piece of innovation forward.

Using the right tool for the job

Every engineer knows that choosing the right technology is crucial and can impact the project’s efficiency, scalability, and success. We invested a lot of time in this part. Blockchains are relatively new. However, the variety of flavours is overwhelming.

We have blockchains that are privately managed by an organisation (permissioned), like Hyperledger Fabric and Sawtooth. On the other hand, we have public blockchains, and everyone can build Defi apps and scrutinise every transaction being committed, like Bitcoin, Ethereum, and Algorand.

In the pursuit of the best tool for the job, we decided not to go with a permissioned blockchain because every participant would have to run a node to be part of the protocol and have guarantees that there isn’t a Byzantine participant changing the transactions in their favour. We chose Algorand, a permissionless blockchain, because it offers everything we need, such as: i) fungible tokens and non-fungible tokens are treated as first-class citizens; ii) fast block finality, around 3.3 seconds; iii) low transaction fees; iv) written in Golang, the blockchain code is straightforward to analyse.

For the front-front end, we had another tough decision to make between writing the apps in their native language platform, maintaining different source codes, or choosing Flutter with Dart has a single source code that would compile for the various platforms (android and IOS). We decided to go with the latter because we were only two developers couldn’t afford the extra time to develop the same thing.

Challenges

Web3 was a greenfield for us. In my thesis, I have changed code in blockchains to integrate threshold signatures, but I never had the opportunity to write a smart contract to solve a real problem. The first challenge appeared when we started developing the smart contract purely in teal (stack machine language). Our first solution was simple to write but hard to maintain, so we adopted pyteal as our abstraction over teal. This lead to our second challenge. The rapid pace of evolution of Algorand and other web3 technologies are astonishing. Things we initially had designed and couldn’t implement were possible after some weeks. We had to revise our solution 2 or 3 times to use the best approach to the problem. At the time of this writing, there are new abstractions over teal and unit testing frameworks that we could adopt.

One of our last challenges was to guarantee that there would be no security problems in the smart contract. We solved this problem by analysing different execution paths and simulating Byzantine transactions.

Where to go from here?

The first Crossapp concept had a simple objective: allow Crossers to pay for their lunch making use of a company copayment benefit. In my opinion, this was a success; however, there is room for improvement and the addition of new features to the app. For example, we could add loyalty points or fitness points to add some gamification to the day-to-day tasks. To sum up, this app offers numerous opportunities that we can still explore and I encourage all Crossers to drive innovation forward, helping us to make our Crossapp even better or promoting new initiatives just like I did.

Jorge Pereira
Consultant

Leave a Reply