We have all heard that dApps exist. We also know that they are programs that work in a decentralized way. However, it’s not a good idea to start learning them from scratch. There are quite a few services designed for novice web3 developers. Next we will get acquainted with them. At a minimum, we will need sample code in Solidity, user manuals and templates of the most common applications. More often than not, the specialized Solidity programming language is used to write dApps. However, these programs can also be written in other programming languages.
Using templates for DeFi applications
The best place to start your introduction to the world of Web3 is with the Cookbook, where Solidity templates, smart contracts and examples of web3 resources implemented with them are widely available.
Available categories to search:
- Tokens.
- NFTs.
- Sales.
- DAOs.
- Finance.
- Utilities.
In each of the categories, you can further narrow the search area by setting the necessary tags. For example, to add support for USDT cryptocurrency to your application, you can download the proven program code for such integration from here. And to write a gift box with ERC20, ERC721 and ERC1155 tokens, you can just take the code from here and change it a little.
What programming language to use
More experienced developers can use Solidity templates. And those who see their future with the Ethereum network will find a full programming guide for this blockchain here. The Web3 guide will help novice developers. Many of the skills listed here, such as checking wallet balance functions, creating a transaction, and creating and running a smart contract will be similar for the Ethereum network as well as other blockchains.
It’s no secret that many people program in Python. And these specialists don’t want to learn another programming language, Solidity, just to create smart contracts. The way out is to use the experimental programming language Vyper. It is similar to Python in everything, but has its own specifics related to creating DeFi applications. The most experienced developers, who care about the high anonymity of DeFi applications and other advanced features, use the Rust programming language. Little-known blockchains use little-known programming languages, such as Cairo and Sway.
However, more and more programmers are mastering tools and blockchains that allow them to write DeFi applications using common and familiar programming languages, such as Python and JavaScript.
DeFi frameworks
In addition to programming languages, we will need frameworks. This is a set of software tools for developers with which to organize the structure of a project and work with it conveniently. At the same time, you can immediately test and compile your projects into executable code. DeFi developers should pay attention to frameworks such as Hardhat, Truffle, and Brownie. They include tools that automatically check for logical errors in smart contracts. This is an extremely important tool for both the novice and experienced developer. After all, a missed error in a smart contract can lead to the loss of a huge amount of money.
Hardhat is an Ethereum development environment for professionals. It is a great way to automate all the routine operations related to writing smart contracts and creating DeFi based on them. At the same time, the framework has an important advantage – written programs can be run locally, without the need to connect to the blockchain. This significantly speeds up the development process.
Truffle has already become a “must-have” tool for DeFi developers. It allows you to write smart contracts in the familiar JavaScript programming language.
Brownie is an analog of the Truffle framework, and it is similarly used for developing smart contracts in Solidity, testing them, and deploying them. However, its main difference is that it doesn’t use the JavaScript programming language, but rather the Python programming language. In addition, Brownie includes software libraries for smart contracts, various versions of compilers, and tools for finding bugs in smart contracts. Solidity and Vyper programming languages are supported.
You can also take advantage of the increasingly popular frameworks such as Embark, Buidler, and dapp.tools).
SDK for working with DeFi
Programmers write code inside an SDK (Software Development Kit). The SDK is a powerful platform where the code is easy to work with and, if necessary, the code can be compiled to a workable program. DeFi developers can try working with these SDKs:
- EthFiddle. The simplest smart contract in the Solidity programming language can be written and compiled directly in the browser here.
- Scaffold-ETH. Frontend, which allows you to work conveniently with smart contracts.
- Gelato. Backend tool for working with smart contracts. In addition to the Ethereum network, it allows interacting with BNB, Avalance, Cronos, Arbirtium, Optimism blockchains.
- Etherspot. Everything you need to interact with various blockchain wallets.
- Yieldster SDK. Perfect for those who want to write DeFi in Python.
- JavaScript SDK. Suitable for developers who want to write DeFi applications in the JavaScript programming language.
There are also quite a few software libraries that expand the functionality and degree of protection of smart contracts.
More tools for working with DeFi
Experienced developers use numerous additional tools to create DeFi applications. Some of them include:
- IFPS service, designed to store data that is used by the blockchain.
- Ethereum Name Service (ENS) or another domain name service that allows a DeFi application to use a decentralized domain name.
- TheGraph and Chainlink services that allow blockchain-based applications to communicate with programs that do not use blockchain. DApps need a way to read and transform data from smart contracts. TheGraph offers a hosted GraphQL indexing service for your smart contracts.
- A Dune analytics service that conveniently displays the data your blockchain uses to run your app.
But users should also be able to interact with smart contracts. To write Frontends for dApp, pay attention to:
Using such services will be enough to create complex applications like DEX, Swap, yield farming, borrowing protocols.
What basics you should know before creating dApps
When creating dApps you should know the basics on which the technology of the decentralized registry relies. The first and foremost is the transaction validation algorithm. The most commonly used algorithms are Proof of work (which Bitcoin uses) and Proof of state (which the cryptocurrency Ethereum recently switched to). In addition to these basic algorithms, there are also quite a few other consensus algorithms. However, they are not as widespread as Proof of work and Proof of state algorithms.
Why we need consensus algorithms
With the existence of a consensus algorithm, all participants in the network can be assured that all transactions are seen and handled equally by all participants. The confirmation of this rests on a decentralized registry called blockchain. If we are sure that the blockchain is running smoothly and without glitches, it’s time to move on to the other variables that our DeFi app will use.
Cryptocurrency wallets
Since our future app is related to decentralized finance, it will use the numbers of the cryptocurrency wallets between which the transactions will take place. The in-demand app will have integration with MetaMask, as it is the most common browser-based cryptocurrency wallet.
Test networks
Because working in decentralized networks is associated with the risk of losing money, developers initially run their applications in a test network. To do this, they simply specify the settings of the test cryptocurrency network before creating the application. The tokens or coins in such a network have no value and can be safely experimented with.
Smart Contracts
Next, we are already theoretically prepared enough to understand the system of “smart contracts”. Using a blockchain, a smart contract makes transactions between cryptocurrency wallets according to criteria that are set in the software code. Blockchain ensures that the transaction is executed and tokens, coins, NFTs or other digital assets are transferred between network participants. In turn, DeFi applications are further built from smart contracts as building blocks.
To reduce the risk of errors, the contracts are first tested and compiled individually.
Virtual machine
The more complex the software code of a decentralized application, the more relevant it is for the application to use a virtual machine. Ethereum Virtual Machine (EVM) is best known, but other blockchains also have their own virtual machines. They all operate in a similar way. The DeFi application uses an EVM or other virtual machine. It uses parameters such as “gas” and “gas price” to calculate the computing power required to execute DeFi smart contracts. We will talk about them further below.
The price of gas
To keep the virtual machine from being overwhelmed by empty transactions and spam, parameters such as “gas” and “gas price” are used. “Gas” is a fee that is charged to the smart contract. Depending on how busy the network is, this commission (“gas price”) can go up or down. If the network is loaded, the “price of gas” goes up; if the load on the network goes down, the “price of gas” goes down.
Conclusion: What will it take to create DeFi?
This article lists a lot of basic and advanced software tools for creating DeFi applications. To summarize, to develop DeFi, you first need to learn the basics of decentralized technology.You need to know what the consensus algorithm is, what the decentralized registry is, the smart contract, the virtual machine, the “gas” and the “gas price”.
You learned that DeFi is a program assembled from smart contracts like building blocks. So we will first need the skill of writing and compiling smart contracts. At first, only the Solidity language was used to write smart contracts. However, more and more developers are now offering the ability to write smart contracts in other programming languages. Therefore, the DeFi developer needs to constantly evolve, learn new things, and experiment. So, in this article we explored what tools exist to create dApps. In the next article we will create our first decentralized app.