Learnings from my first blockchain app (DAPP): the TokenCreator

Valentin Seehausen
5 min readNov 29, 2021

I finished programming my first blockchain app (DAPP — decentralized app) yesterday. It has been a weekend project with the main goal of making a blockchain developer out of me. This article describes the TokenCreator and my learnings as a blockchain programmer: Tools, test, gas optimization, and how to connect a wallet to your web3 application.

This is a technical article that targets developers. Github Repo here.

Most importantly: The TokenCreator.

The dashboard of the TokenCreator

Purpose

I finished the prototype and submitted it to Celo’s Make Crypto Mobile Hackathon. I come from the community currency space and I support Celo’s mission of financial inclusion. Celo basically is an Ethereum clone with very low gas fees. They also have a special feature where users can send transactions to mobile phone numbers and even light clients for phones, so they take decentralization seriously. They also invest a lot into their ecosystem and I hope I will win a prize in their 2.5 million USD hackathon, as this would allow me to focus on the TokenCreator for a few weeks.

I personally think the next big thing in blockchain will be “user-generated” tokens, as regulations are slowly coming in place. This means that consultancies and law firms will be able to help companies raise money for specific purposes and issue tokens. Startups will start to raise money over tokens with a slow and steady approach, instead of ICOs. Last but not least, community currencies (like Grassroots Economics) will hopefully help communities to grow wealth in poor communities and countries.

So I decided that the project will be a TokenCreator. This fits perfectly into the mission of Celo: The generated tokens can be used with the mobile wallet Valora, so I did not have to take care of the end-users. The TokenCreator is mainly a tool for issuers of tokens (see figure 1).

Figure 1: Here you can see the two dimensions of Issuance and Usage of a token and the three lifecycle steps from the User over the tool to the Token.

The TokenCreator

The TokenCreator creates tokens that inherit from ERC20 functionality (called SimpleTokens). This is a proof-of-concept and the roadmap included many more different and interesting token features. Especially, life-minting and automated payouts will be interesting features (for basic income tokens). The TokenCreator allows users to issue and own their own ERC20 tokens (see figure 2).

Figure 2: This image describes the simple user flow of the token creation.

Straight forward concept, perfect learning project.

Here is what I learned

Blockchain offers a great toolset and environment

Blockchain development is quite simple. Yes, simple. Compared to App development Dapp development is quite programmer-friendly, because you create one single “money lego peace” in a huge ecosystem. As you see above, most of the legos are in place:

  • The blockchain is the backend
  • The wallets are the user interface (for the tokens)
  • The blockchain adds security

You have the backend, a user interface, and security. You can only focus on your idea and start programming right away. How fun!

So when you have a background in frontend development and know something about backend-programming, I can highly recommend starting. Start exactly here and walk your way through the famous CryptoZombies and at least half the Ethernaut course.

Hardhat and Ethers rule

You will have to make a decision between Truffle and Hardhat, where Hardhat is the more professional option. You can run an Ethereum blockchain locally and even clone the actual mainnet’s state. Awesome!

For a Web3 frontend, you will have to make the decision between Web3Js and Ethers. Again I decided on the “more professional” version.

Both Hardhat and Ethers came out in the last years and both gained a lot of popularity, but still, most tutorials use Truffle and Web3. You have to decide, but if you can read a library’s documentation, I would suggest Hardhat and Ethers.

Testing smart contracts is a breeze

It is purely amazing how great the tooling of Hardhat and Waffle works. If you ever read Clean Code you will ❤ blockchain development!

Test-driven development for smart contracts with Truffle and Hardhat.

Blockchain frontend is entirely occupied by React

Well, not entirely… One small community actually uses Vue. I really liked React a few years ago, but Vue is faster, better, sexier, easier. It’s actually funny that the decentralized world uses the software of Facebook (well, now Meta). All start kits and tutorials focus on React, so I was actually considering using React just to allow other blockchain devs to jump on the project. Developer sourcing is a very important consideration for software projects!

Anyway, I decided on Vue and I like it. I used a sweet little starter kit that I had to modify nearly all over, but it was a good start.

Benchmarking gas costs is possible

As a blockchain developer, you always want to optimize your storage. Writing storage is the most expensive action a smart contract can do, and so most smart contracts will rather calculate data on every call than save data. Many getter calls will therefore iterate and filter data from the storage.

TokenCreator saves the tokens of each user in a database. I was wondering if it is better to save a mapping of arrays or an array where I iterate through. I researched for hours without a result and thus I did the benchmarks myself. I had two options, Database 1 (with saving a mapping of address (of the user) to an array (of tokens)) and Database 2 (where I saved an array of tokens and a mapping from the token’s address to the token’s data).

Here is the code:

And here is the output using hardhat-gas-reporter:

Surprisingly database_1 is cheaper. But I made very simple benchmarks and I am sure there are better ways to save data.

Use web3modal to connect a wallet to your web3 application

You can also add the wallets yourself, but Web3Modal is actually useful.

Conclusion

Coding in Blockchain is not as hard as I expected. When you are afraid to jump in, I can only encourage you to start now. If you need help, drop me a line.

About the author

Valentin Seehausen is a project manager at the Frankfurt School Blockchain Center (FSBC) and the COO of the Digital Euro Association (DEA). His company Open Currency Technology creates applications that drive the tokenization of everything.

--

--

Valentin Seehausen

Founder www.SevenDots.Art | Board member @DigiEuro | CTO @itsa_global | Mentor @defitalents | PM @FSBlockchain | #DYOR #NFT #CBDC #DeFi