Back to top
Published on -
July 29, 2020
Written by:
Thang Pham

My first Blockchain Hackathon

As someone who only started learning blockchain a month ago, I will share my experience learning the technology and developing a blockchain project.

WANT

As someone who only started learning blockchain a month ago, I will share my experience learning the technology and developing a blockchain project.

Recently, I participated in ETHGlobal’s Hack Money hackathon as team WANT a Nintendo Switch. I'm really excited because this was my first time participating in a blockchain hackathon. At the same time, I know that there still are a lot of things I need to learn to catch up with my other teammates who have more experience in the field than me.

Diving into Blockchain

The theme of Hack Money is building projects for the Decentralized Finance (DeFi) ecosystem. At first, the idea of using a decentralized network to develop financial services and products was confusing to me. I asked myself a lot of questions about smart contracts, cryptocurrencies, how the money is distributed between people, what determines a coin value in blockchain, and so on. After hours of reading online documents and asking my teammates, the concepts of Decentralized Finance became more clear to me and I started working on the hackathon with my team. Curvegrid's document gave me a detailed overview of the blockchain and really helped me with my learning process.

Brainstorming the Project idea

Time is short because each team only has only four weeks to build the project. On top of that, we had decided to allocate no more than ten percent of our work hours to the hackathon. For the first two weeks, we spent most of time brainstorming the project idea. Initially, we wanted to build a blockchain gateway platform connecting to Animal Crossing. However, because none of us had a Nintendo Switch to test the project 😞 and the Switch was out of stock almost everywhere, we decided to change our project idea. We wanted something unique and fun, so we went through a lot of discussions and online meetings to pick an idea to work on.

In the end, we decided to build a token pool exchange, which gives WANT tokens each time user deposits an ERC20 token to the pool and a random token from the pool when a user redeems a WANT token. At first, this didn't look like it was related to DeFi. However, the fun part came later when we actually created the WANT token contract to make our project better fit the DeFi theme.

Creating WANT Token Contract with Solidity

Within the team, one other person and I were responsible for building the smart contract. To do this, I needed to learn Solidity, so I spent a few days going through the tutorials on CryptoZombies. The website provides detailed and interactive coding lessons, which helped me a lot when learning to code in Solidity. After becoming more familiar with the language, I started building the smart contracts for the WANT token.

However, once I started actually developing the smart contract, I realized that programming in Solidity was not as easy as I expected. Solidity has a naming convention in which private variables begin with an underscore. As someone who has mostly programmed in C++ and Python, naming a variable starting with underscore is not a normal thing for me. I usually forget that my variables start with underscores, resulting in a lot of compile errors.

Also, when building a blockchain DApp, one thing to keep in mind is that efficiency is not the priority. In blockchain, writing a variable can be more expensive than reading ten variables. This can make the process of developing a smart contract repetitive and counterintuitive. For example, in some situations, to avoid writing/updating, re-creating an array multiple times is better than storing the array and using it directly.

WANT's Payout Algorithm

WANT Presentation Diagram

After we finished building the core contract with Deposit and Claim functions, we then needed to design a Payout algorithm that would give users a specific amount of WANT Tokens each time they deposited an ERC20 token. We want users to have an incentive to keep depositing tokens, even with the knowledge that the token they receive upon redemption is completely random. We also want to incentivize users to add tokens to the pool early on. To achieve these goals, we came up with a Payout algorithm which takes into account the token's real value and its rarity in the pool. The amount of WANT tokens user will receive when depositing a token X can be described as


payout = X_real_price_in_eth * (1 - X_rarity_in_pool) * WANT_constant


We calculated X_real_price_in_eth by using Uniswap for price exchange. For deploying/testing the smart contracts and integrating those contracts into our application, we used Curvegrid's SaaS platform MultiBaas.

More details about the project can be found at our Github repo. With this Payout algorithm, we believe that users will have a tendency to deposit tokens to the pool and redeem the received WANT tokens to get some profits.

Wrap up

Overall, participating in the hackathon was a valuable experience for me, in which I could learn more about blockchain and DeFi. I also had a chance to meet new people and experience new things such as programming in Solidity, participating in a virtual hackathon and working in a remote environment.

If you have fun using our product, don't forget to give us a star and check out our other projects on our github page. More details about how Curvegrid participated in the Hack Money hackathon can be found here.

Disclaimer: The payout algorithm is not perfect because we are not finance experts. For the hackathon, we only deployed a test version on the Rinkeby test net. Also, it's good to keep in mind that if deposting tokens doesn't give you any profits but makes you lose your money, it's because of fate not the algorithm 😃.