{"id":485721,"date":"2026-07-01T01:08:59","date_gmt":"2026-07-01T01:08:59","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=485721"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=485721","title":{"rendered":"A 3.5MB Web3 Messenger: Indie Development on a Zero Budget"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><strong>A WONDERFUL FUTURE<\/strong><\/p>\n<p>Technology is advancing at an astonishing rate. It seems like only yesterday that domestically produced KR1810VM86M microprocessors with a clock rate of just 8 megahertz appeared, forever dividing our lives into \u201cbefore\u201d and \u201cafter.\u201d And a set of eight K565RU7 memory chips (similar to the Intel 41256) provided a RAM capacity of 256 kilobytes, a fantastic value for its time.<\/p>\n<p>Back then, it seemed that with such rapid development, humanity was about to transcend the galaxy and rush to other worlds. Today, these figures only evoke a smile, but it was precisely with such advances in computing technology in the 1980s and 1990s that our journey into the future world of ones and zeros began.<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9eb\/3c0\/690\/9eb3c06906b2640d87f3b3f43d406ba1.jpg\" width=\"221\" height=\"228\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/9eb\/3c0\/690\/9eb3c06906b2640d87f3b3f43d406ba1.jpg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9eb\/3c0\/690\/9eb3c06906b2640d87f3b3f43d406ba1.jpg 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>I remember how, a couple of years after the release of OS DOS-6.22, I started the Windows 95 installation for the first time. I set my alarm two hours ahead so as not to miss the spectacular installation completion window, on my first DX386 with 40 MHz in turbo mode, and went to bed.<\/p>\n<p>A little later, I was writing my first programs in Turbo Basic. And mind you, they were programs, not applications. After all, they didn\u2019t require any drivers or installation packages. Everything ran in interpreter mode, that is, within the programming environment itself. The size of such programs never exceeded a few kilobytes.<\/p>\n<p><strong>HIGHER AND HIGHER<\/strong><\/p>\n<p>Time passed. The technological boom seemed endless. Processors, memory, the internet\u2014everything was developing rapidly, and no one thought about limitations anymore. The first instant messengers appeared. ICQ, with its unique \u201ccuckoo,\u201d was heard in every office. I remember at some companies, department heads even fined their employees for using instant messengers on their work computers. The first programs for automating enterprise accounting appeared. 1C seemed to be familiar to everyone. So what, a built-in programming language with a Russian dialect\u2014that\u2019s no joke. Those were the days. Everything was spinning and sparkling inside system units, proudly standing on the shelves of computer stores. Gone are the Trident TVGA and Cirrus Logic computers, beloved by many gamers, with one megabyte of memory, Creative Sound Blaster audio, and DOOM for DOS\/4GW.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c03\/4fc\/ba7\/c034fcba74276f78c9100644f772eaf0.jpg\" width=\"547\" height=\"365\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/c03\/4fc\/ba7\/c034fcba74276f78c9100644f772eaf0.jpg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c03\/4fc\/ba7\/c034fcba74276f78c9100644f772eaf0.jpg 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>Well, never mind the hardware. But let\u2019s look at what\u2019s happened to the software. It\u2019s grown to gigantic proportions, eating up all the free space on the hard drive. I remember playing Alladdin before, and a few floppy disks were enough to load the game onto a virtual drive. Now, GTA5 requires about 100+ GB just for the minimum installation, and GTA6 is on the way. But I\u2019m no longer a gamer; the times have changed.<\/p>\n<p>Having written a bunch of applications in Visual Basic 6, I was shocked by the release of the new version with the .NET prefix, thinking Microsoft had gone crazy. What .NET? Isn\u2019t what\u2019s available enough for anyone? Now a modern studio from those same Microsoft developers weighs in at about 220 GB, and that\u2019s despite the fact that Turbo Basic, which essentially made me a programmer, weighed only 950 kilobytes. That\u2019s technology in all its glory, my friends.<\/p>\n<p><strong>CLEVER AND BOLD<\/strong><\/p>\n<p>Modern programmers are now releasing programs that consume hundreds of megabytes of memory and require powerful processors for simple tasks. This isn\u2019t the 1990s, when a game engine, drivers, and the game itself had to fit into 640 KB of MS-DOS RAM.<\/p>\n<p>Why is this happening? Is it the developer\u2019s laziness or a conscious economic and technical choice. There are several reasons:<\/p>\n<ul>\n<li>\n<p>For businesses, it\u2019s more important to launch a product before competitors.<\/p>\n<\/li>\n<li>\n<p>Why use vector graphics if the user has 8 GB of RAM?<\/p>\n<\/li>\n<li>\n<p>Writing cross-platform applications for different operating systems.<\/p>\n<\/li>\n<li>\n<p>Why write something from scratch when there are already existing library support sets?<\/p>\n<\/li>\n<li>\n<p>They write without optimization just to deliver the project, and then they\u2019ll be screwed.<\/p>\n<\/li>\n<\/ul>\n<p>These days, installing a new application or deploying a cloud service is quite easy. But these developers, despite the fact that Nginx, Python, Node.js, and other applications weigh pennies, are often thousands of times larger. Consumers of such software are frankly reluctant to install new apps on their smartphones, complaining about a lack of free space.<\/p>\n<p>There\u2019s a strange trend: the larger the app size, the higher the hardware requirements, and vice versa: the more powerful the hardware, the larger the apps become. But when will this resource waste reach its limit?<\/p>\n<p>I\u2019m providing an example of the \u201cHello World\u201d app code in Java in Android Studio, which, after building, weighs in at about 7 megabytes. But if you remove all the junk from the project, the size drops to 42 kilobytes!<\/p>\n<pre><code class=\"cs\">package com.example.helloworld;import android.os.Bundle;import android.util.Log;import androidx.appcompat.app.AppCompatActivity;public class MainActivity extends AppCompatActivity {    private static final String TAG = \"MyActivityTag\";    @Override    protected void onCreate(Bundle savedInstanceState) {        super.printStackTrace(); \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        \/\/ \u0412\u044b\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438 \"Hello World\" \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c Android (Logcat)        Log.d(TAG, \"Hello World\");    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>I understand that many developers will probably start throwing slippers at me now. How can this be, they\u2019ll say, after all, AppCompat + Materials is convenient, fast, and beautiful, plus it ensures backward compatibility across devices. For example, someone on Android 4.4 wants to use a modern app, but without AppCompat it won\u2019t work. An exception will be thrown, and the app will crash. That\u2019s right, gentlemen, it will crash. But the question is, who will want to use KitKat in 2026? The answer is simple: Google itself. It\u2019s Google that\u2019s doing everything it can to make you use its \u201cBibles\u201d and bloat your apps. It\u2019s tomorrow\u2019s bread and butter for them. You bloat your apps, and Google is readying the next device with more memory.<\/p>\n<p>Take Google\u2019s Material Design as an example. This system has everything: ready-made component sets, shadow styles, and graphic assets. It sounds great, but the basic interface can be designed manually using standard tools. In this case, the application size will increase by only 200-300 kilobytes (the size of a single JPEG file), and you won\u2019t have to burden your build with an extra 5 megabytes of library code. Sounds brilliant, right?<\/p>\n<p>The same applies to working with sockets, databases, and cryptography. Low-level tools for these tasks weigh next to nothing, while providing maximum performance and reliability. For example, the OkHttp library is a powerful network engine that handles all the dirty work of working with sockets. Popular tools like Retrofit, Ktor Client, or Volley, on the other hand, are essentially just high-level add-ons. While convenient, they don\u2019t add anything new to the application\u2019s functionality.<\/p>\n<p>I hope these examples have clearly illustrated the essence of true optimization in application development. There\u2019s no point in measuring the performance of your code if the application itself is made of cinder blocks.<\/p>\n<p><strong>TELEGRAMS AND EVERYTHING&#8230;<\/strong><\/p>\n<p>Let\u2019s return to the original topic. Since the article is titled \u201cWeb3 Messenger\u2026,\u201d I\u2019ll smoothly get to the point, describing ready-made solutions designed for messaging. These are the so-called instant messengers. Take the beloved Telegram, for example. Its package size is about a hundred megabytes. But what\u2019s inside? Pavel Durov, the author of the Telegram project, proudly declared that they don\u2019t use third-party libraries and write all the components themselves. Yes, that\u2019s true, and deserves respect. But there\u2019s one small detail here. Why even write everything from scratch? After all, the operating system itself already has default modules that you can simply pull into your application. But this is the company\u2019s policy, and therefore, from their perspective, it\u2019s correct.<\/p>\n<p>I\u2019ll give you another example. When I first started developing my messenger, I needed to implement video calls over the P2P protocol. The first thing I looked at was WebRTC technology, as it seemed the ideal solution for video communication. But when I saw the size of this SDK, I was horrified \u2013 the raw size was almost 50 megabytes. Even using the stripped version, I still gained an extra 25 megabytes in my package. Even writing my own WebRTC engine in C++ isn\u2019t guaranteed to be any smaller.<\/p>\n<p>I chose the path of least resistance and maximum impact. I figured, since the WebRTC engine is built into the Chrome browser on Android, why not connect to it directly? By attaching Chrome to a WebView, I got this beautiful solution\u2026<\/p>\n<pre><code class=\"java\">webView.setWebChromeClient(new WebChromeClient() {  @Override  public void onPermissionRequest(final PermissionRequest request) {    runOnUiThread(() -&gt; request.grant(request.getResources()));  }});<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Next, I initiated a connection to this library through a separate JavaScript class and voila, everything worked without problems:<\/p>\n<pre><code class=\"javascript\">    class CallManager {        constructor(localVideoSelector, remoteVideoSelector) {            this.localVideo = document.querySelector(localVideoSelector);            this.remoteVideo = document.querySelector(remoteVideoSelector);            this.peerConnection = null;            this.localStream = null;            this.remoteStream = null;            this.pendingCandidates = [];            this.config = { iceServers: [{ urls: \"stun_address\" }] };        }      \/\/...<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>If you\u2019re a Java programmer, and I\u2019m sure you are, you\u2019ll notice that the package size with this approach will increase by exactly \u201c0\u201d bytes instead of 25-50 megabytes.<\/p>\n<p>Here\u2019s a list of installation package sizes (APKs) for various messengers:<\/p>\n<ul>\n<li>\n<p><strong>Telegram<\/strong>\u00a0= 100 \u041c\u0411.<\/p>\n<\/li>\n<li>\n<p><strong>WhatsApp<\/strong>\u00a0= 112 \u041c\u0411.<\/p>\n<\/li>\n<li>\n<p><strong>Viber<\/strong>\u00a0= 167 \u041c\u0411.<\/p>\n<\/li>\n<li>\n<p><strong>Signal<\/strong>\u00a0= 65 \u041c\u0411.<\/p>\n<\/li>\n<li>\n<p><strong>Discord<\/strong>\u00a0= 130 \u041c\u0411.<\/p>\n<\/li>\n<li>\n<p><strong>Elyon (Accord)<\/strong>\u00a0= 3.5 \u041c\u0411. (developer your humble servant)<\/p>\n<\/li>\n<\/ul>\n<p>With a total app size of 3.5 megabytes, I managed to squeeze in not only video calls but even my own crypto economy. Furthermore, I also implemented a full-fledged messenger with private channels, bots, and even built-in artificial intelligence. All this was achieved through integrations, external APIs, and hand-written code. The messenger\u2019s capabilities were significantly expanded through the use of user bots. Interaction with external services turned the app into a platform with unlimited possibilities. And this, my friends, was all done on a zero-budget basis. I acted as both the project\u2019s client and its implementer.<\/p>\n<p><strong>Web-3: What is it and why is it needed?<\/strong><\/p>\n<p>So, a little background. Web3 is a concept for a new generation of the internet. Its core idea is the decentralization of computing power. This internet allows, instead of using a single powerful server, to distribute the load across other computing units. Therefore, we are now dealing with blockchain technologies, where cryptographic addresses or wallets are used instead of traditional accounts (phone numbers or email addresses).<\/p>\n<p>The most important criteria for the transition to Web3 are its speed and reliability. The integrity of all transactions conducted via blockchain allows, for example, financial transactions to be recorded without fear of counterfeiting.<\/p>\n<p>Cryptocurrency itself is simply a consequence of the development of blockchain technology. It\u2019s not hard to guess which came first: blockchain or Bitcoin.<\/p>\n<p><strong>HOW I USE IT<\/strong><\/p>\n<p>While developing my messenger, I faced many challenges. One of them was how to implement an internal payment system to provide access to restricted user resources. In other words, I needed to come up with a mechanism for monetizing paid subscriptions to private channels and other paid app services.<\/p>\n<p>Access to such channels is usually closed to regular users. To view the content, you\u2019ll need to pay for access. But even if the user\u2019s wallet is empty, they can still receive donations or earn a few coins within the app. There are several ways to do this. One is to collect rewards from prize payouts by playing built-in games.<\/p>\n<p>It\u2019s clear that dealing with real money is difficult and dangerous. You need to register a business, calculate taxes, keep track of all users, and then transfer personal data to the relevant authorities. But I took a different approach. I launched my own crypto economy and issued my own \u201cbitcoin\u201d right within the messenger.<\/p>\n<p>In reality, it all seems quite simple. Anyone can buy nominal cryptocurrency through a terminal at a nearby supermarket. For example, you can exchange Ethereum for the app\u2019s coin by sending the Ethereum to the smart contract specified in the messenger profile. This smart contract will automatically transfer the received amount to the user\u2019s wallet in the desired currency. The credited amount will now appear in the user\u2019s account. There is no commission in the traditional sense, but there is a fee for so-called \u201cgas.\u201d \u201cGas\u201d or \u201cfuel\u201d is the fee for a completed transaction to the blockchain itself in Ethereum. Incidentally, this is what miners earn when they register other people\u2019s transactions, while chugging away on their video cards in the kitchen. \u201cGas\u201d costs pennies. Even a single cent on the balance is enough for dozens of such transactions.<\/p>\n<p>So, when a user subscribes to a private (paid) channel, their coins are deposited into the channel owner\u2019s wallet. The beauty of web3 technology is that all transactions can be viewed on any blockchain online by entering the desired wallet address. Moreover, it\u2019s transparent for all transactions over any period of time. No one knows the true wallet owners; it\u2019s an anonymous system. Therefore, no restrictions apply to them.<\/p>\n<p>Below is an example of how I use web3 for some tasks:<\/p>\n<p>An example of creating a crypto wallet:<\/p>\n<pre><code class=\"cs\">public string CreateWallet(){    var ecKey = EthECKey.GenerateKey();    string privateKey = ecKey.GetPrivateKey();    var account = new Account(privateKey);    return $\"{account.Address}:{privateKey}\";}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Here, after generating a unique key, a private key is created. The final wallet address is then extracted from the private key.<\/p>\n<p>Now things get a little more complicated. Let\u2019s get the balance (remaining balance) of the game contract wallet:<\/p>\n<pre><code class=\"cs\">using System;using System.Numerics;using System.Threading.Tasks;public async Task&lt;long&gt; GetTreasuryBalance(){    var web3 = new Web3(url-RPC-server);    string treasuryBalAbi = \"[\u0437\u0434\u0435\u0441\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430]]\";    var treasuryBalFunc = web3.Eth.GetContract(treasuryBalAbi, GAMES_CONTRACT).GetFunction(\"treasuryBalance\");    BigInteger totalTreasuryTokens = await treasuryBalFunc.CallAsync&lt;BigInteger&gt;();    decimal balanceDecimal = Web3.Convert.FromWei(totalTreasuryTokens);    long integerBalance = (long)Math.Truncate(balanceDecimal);        return integerBalance;}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>As you can see from the code above, a special variable type, BigInteger, is used. Since web3 doesn\u2019t support floating-point values, an integer type with a large number of zeros is used here. For example, my contract uses a whopping 18 zeros after the one. To reflect a balance of one coin, I would write: 10000000000000000000. This is a reversible value that can easily be converted to a decimal.<\/p>\n<p><strong>BUILT-IN WEB3 GAMES<\/strong><\/p>\n<p>Now I\u2019ll tell you a little about a special feature that helps users not only spend their coins but also earn them. Considering that my cryptocurrency is virtual money and not real money, I decided to create online games where players can receive rewards for their winnings. For example, if you have a zero balance, then when you launch a game like roulette, you\u2019ll enter demo mode. You can play endlessly, and it won\u2019t affect your wallet balance. If you win ten times your initial deposit in demo mode, you\u2019ll receive one real coin in your personal wallet. You can then play with the coins you\u2019ve earned, which will have a real impact on your bankroll.<\/p>\n<p>Currently, I\u2019ve written several fairly simple arcade games in HTML format. Some of them have already been integrated with Web3. The following games are currently available:<\/p>\n<ul>\n<li>\n<p>BlackJack is an arcade card game (similar to \u201cOchko\u201d or \u201c21\u201d);<\/p>\n<\/li>\n<li>\n<p>Roulette is reminiscent of casino roulette with a wheel and bets;<\/p>\n<\/li>\n<li>\n<p>Slots is a rather dumb game, in my opinion, where you spin three wheels for luck.<\/p>\n<\/li>\n<\/ul>\n<p>All these games were written in a couple of evenings, so please don\u2019t criticize me too much for the poor graphics. The goal was to integrate them into the messenger economy and make betting possible. By the way, if you\u2019re interested in improving these games or writing your own, I\u2019d be happy to collaborate. Cookies and coffee are on me.<\/p>\n<p>Below is a screenshot of the game \u201cBlackJack.\u201d<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/46e\/8b4\/06d\/46e8b406de06c55c2ff5f61539eeb734.jpg\" width=\"1080\" height=\"2340\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/46e\/8b4\/06d\/46e8b406de06c55c2ff5f61539eeb734.jpg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/46e\/8b4\/06d\/46e8b406de06c55c2ff5f61539eeb734.jpg 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p><strong>SECRET CHATS<\/strong><\/p>\n<p>My messenger is very different from the aforementioned services. One of its distinguishing features is the absence of a message cache on the backend. In other words, the service doesn\u2019t store any user correspondence at all. The database only stores a compressed message digest, which is deleted immediately after the subscriber launches their messenger and reads the message addressed to them.<\/p>\n<p>This approach prevents the database from becoming bloated and users from accidentally leaking their correspondence data. However, to ensure absolute secrecy, I also implemented an E2E encryption subsystem. This method uses cryptographic keys to encrypt messages and then transmits them between two users.<\/p>\n<p>It operates on the principle of \u201cend-to-end encryption\u201d and works as follows. Private keys are stored on each user\u2019s smartphone in a closed TEE (Trusted Execution Environment) storage. Public keys are stored on the backend server. As soon as one user activates a \u201csecret chat,\u201d their app immediately requests their interlocutor\u2019s public key. The user then encrypts their message with their interlocutor\u2019s public key and sends it to the server. Once the user logs in, they retrieve this encrypted message and decrypt it with their private key.<\/p>\n<p>The rule here is that only a private key can decrypt a message encrypted with a public key. In practice, the keys don\u2019t encrypt the message itself, but rather the password for another encryption algorithm, which encrypts the message itself. For example, a message is encrypted with the AES algorithm with a password, and the password itself is encrypted with the public key using the RSA algorithm. As a result, two messages are transmitted to the server: the first is the message encrypted with the AES algorithm, and the second is the AES password encrypted with the RSA algorithm. Or in another order, it doesn\u2019t matter. This is a classic end-to-end encryption scheme. In this case, no one but the recipient will be able to read the encrypted message. So Pavel Durov was right when he said he doesn\u2019t have the keys to users\u2019 encrypted messages. They are stored by the users themselves.<\/p>\n<p>Below is a sample code for generating keys and writing them to storage:<\/p>\n<pre><code class=\"cs\">KEYS_HAS_UPDATED = true;try {    KeyPairGenerator generator = KeyPairGenerator.getInstance(            KeyProperties.KEY_ALGORITHM_RSA,             \"AndroidKeyStore\"     );    generator.initialize(new KeyGenParameterSpec.Builder(            \"ALIAS\",             KeyProperties.PURPOSE_DECRYPT | KeyProperties.PURPOSE_SIGN)            .setKeySize(2048)             .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_RSA_PKCS1)            .setSignaturePaddings(KeyProperties.SIGNATURE_PADDING_RSA_PKCS1)            .build());    KeyPair keyPair = generator.generateKeyPair();} catch (Exception e) {    e.printStackTrace(); }<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><strong>CONCLUSIONS<\/strong><\/p>\n<p>The main idea behind this article was to introduce the reader to the practical use of new blockchain-based Web3 technology, using my messenger \u201cElyon\u201d as an example. I tried to explain how easy it is to implement your own economy in your projects and make them paid. With their own smart contract with their own cryptocurrency, any developer can implement paid services without interacting with federal payment systems. <\/p>\n<p>The exchange handles deposits and withdrawals of real money. There, you buy nominal cryptocurrency and exchange it for any other token by specifying the contract address. Withdrawals are roughly the same. You submit a withdrawal order, pay a nominal transaction fee, and transfer the coins back to your real crypto wallet. Then, through the same exchange, you can withdraw your coins in any currency worldwide!<\/p>\n<p>I also shared my perspective on why apps can be unnecessarily large and pointed out the shortcomings of developers writing clean code instead of using complex libraries. I believe that the usability of apps depends largely on their optimization, which is often ruined by excessive use of add-ons [IMHO].<\/p>\n<p>If you\u2019re interested in this topic and would like to join my project, I\u2019d be delighted. Send me a private message, and we\u2019ll discuss the details.<\/p>\n<p>P.S.<\/p>\n<p>My messenger still has many interesting features, but describing them all in one article would be too expensive. You can download the working APK file from my project website and see for yourself that everything works perfectly. This project is fully functional and awaits its regular users. There is no content moderation, no censorship, and no intrusive rules.<\/p>\n<p>Please don\u2019t be too harsh on me for the unprofessional presentation. I\u2019m not a writer, but I wanted to share my ideas with the Khabr audience.<\/p>\n<p>I wish you all success and patience!<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1054174\/\">https:\/\/habr.com\/ru\/articles\/1054174\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A WONDERFUL FUTURETechnology is advancing at an astonishing rate. It seems like only yesterday that domestically produced KR1810VM86M microprocessors with a clock rate of just 8 megahertz appeared, forever dividing our lives into \u201cbefore\u201d and \u201cafter.\u201d And a set of eight K565RU7 memory chips (similar to the Intel 41256) provided a RAM capacity of 256 kilobytes, a fantastic value for its time.Back then, it seemed that with such rapid development, humanity was about to transcend the galaxy and rush to other worlds. Today, these figures only evoke a smile, but it was precisely with such advances in computing technology in the 1980s and 1990s that our journey into the future world of ones and zeros began.I remember how, a couple of years after the release of OS DOS-6.22, I started the Windows 95 installation for the first time. I set my alarm two hours ahead so as not to miss the spectacular installation completion window, on my first DX386 with 40 MHz in turbo mode, and went to bed.A little later, I was writing my first programs in Turbo Basic. And mind you, they were programs, not applications. After all, they didn\u2019t require any drivers or installation packages. Everything ran in interpreter mode, that is, within the programming environment itself. The size of such programs never exceeded a few kilobytes.HIGHER AND HIGHERTime passed. The technological boom seemed endless. Processors, memory, the internet\u2014everything was developing rapidly, and no one thought about limitations anymore. The first instant messengers appeared. ICQ, with its unique \u201ccuckoo,\u201d was heard in every office. I remember at some companies, department heads even fined their employees for using instant messengers on their work computers. The first programs for automating enterprise accounting appeared. 1C seemed to be familiar to everyone. So what, a built-in programming language with a Russian dialect\u2014that\u2019s no joke. Those were the days. Everything was spinning and sparkling inside system units, proudly standing on the shelves of computer stores. Gone are the Trident TVGA and Cirrus Logic computers, beloved by many gamers, with one megabyte of memory, Creative Sound Blaster audio, and DOOM for DOS\/4GW.Well, never mind the hardware. But let\u2019s look at what\u2019s happened to the software. It\u2019s grown to gigantic proportions, eating up all the free space on the hard drive. I remember playing Alladdin before, and a few floppy disks were enough to load the game onto a virtual drive. Now, GTA5 requires about 100+ GB just for the minimum installation, and GTA6 is on the way. But I\u2019m no longer a gamer; the times have changed.Having written a bunch of applications in Visual Basic 6, I was shocked by the release of the new version with the .NET prefix, thinking Microsoft had gone crazy. What .NET? Isn\u2019t what\u2019s available enough for anyone? Now a modern studio from those same Microsoft developers weighs in at about 220 GB, and that\u2019s despite the fact that Turbo Basic, which essentially made me a programmer, weighed only 950 kilobytes. That\u2019s technology in all its glory, my friends.CLEVER AND BOLDModern programmers are now releasing programs that consume hundreds of megabytes of memory and require powerful processors for simple tasks. This isn\u2019t the 1990s, when a game engine, drivers, and the game itself had to fit into 640 KB of MS-DOS RAM.Why is this happening? Is it the developer\u2019s laziness or a conscious economic and technical choice. There are several reasons:For businesses, it\u2019s more important to launch a product before competitors.Why use vector graphics if the user has 8 GB of RAM?Writing cross-platform applications for different operating systems.Why write something from scratch when there are already existing library support sets?They write without optimization just to deliver the project, and then they\u2019ll be screwed.These days, installing a new application or deploying a cloud service is quite easy. But these developers, despite the fact that Nginx, Python, Node.js, and other applications weigh pennies, are often thousands of times larger. Consumers of such software are frankly reluctant to install new apps on their smartphones, complaining about a lack of free space.There\u2019s a strange trend: the larger the app size, the higher the hardware requirements, and vice versa: the more powerful the hardware, the larger the apps become. But when will this resource waste reach its limit?I\u2019m providing an example of the \u201cHello World\u201d app code in Java in Android Studio, which, after building, weighs in at about 7 megabytes. But if you remove all the junk from the project, the size drops to 42 kilobytes!package com.example.helloworld;import android.os.Bundle;import android.util.Log;import androidx.appcompat.app.AppCompatActivity;public class MainActivity extends AppCompatActivity {    private static final String TAG = &#171;MyActivityTag&#187;;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.printStackTrace(); \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        \/\/ \u0412\u044b\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438 &#171;Hello World&#187; \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c Android (Logcat)        Log.d(TAG, &#171;Hello World&#187;);    }}I understand that many developers will probably start throwing slippers at me now. How can this be, they\u2019ll say, after all, AppCompat + Materials is convenient, fast, and beautiful, plus it ensures backward compatibility across devices. For example, someone on Android 4.4 wants to use a modern app, but without AppCompat it won\u2019t work. An exception will be thrown, and the app will crash. That\u2019s right, gentlemen, it will crash. But the question is, who will want to use KitKat in 2026? The answer is simple: Google itself. It\u2019s Google that\u2019s doing everything it can to make you use its \u201cBibles\u201d and bloat your apps. It\u2019s tomorrow\u2019s bread and butter for them. You bloat your apps, and Google is readying the next device with more memory.Take Google\u2019s Material Design as an example. This system has everything: ready-made component sets, shadow styles, and graphic assets. It sounds great, but the basic interface can be designed manually using standard tools. In this case, the application size will increase by only 200-300 kilobytes (the size of a single JPEG file), and you won\u2019t have to burden your build with an extra 5 megabytes of library code. Sounds brilliant, right?The same applies to working with sockets, databases, and cryptography. Low-level tools for these tasks weigh next to nothing, while providing maximum performance and reliability. For example, the OkHttp library is a powerful network engine that handles all the dirty work of working with sockets. Popular tools like Retrofit, Ktor Client, or Volley, on the other hand, are essentially just high-level add-ons. While convenient, they don\u2019t add anything new to the application\u2019s functionality.I hope these examples have clearly illustrated the essence of true optimization in application development. There\u2019s no point in measuring the performance of your code if the application itself is made of cinder blocks.TELEGRAMS AND EVERYTHING&#8230;Let\u2019s return to the original topic. Since the article is titled \u201cWeb3 Messenger\u2026,\u201d I\u2019ll smoothly get to the point, describing ready-made solutions designed for messaging. These are the so-called instant messengers. Take the beloved Telegram, for example. Its package size is about a hundred megabytes. But what\u2019s inside? Pavel Durov, the author of the Telegram project, proudly declared that they don\u2019t use third-party libraries and write all the components themselves. Yes, that\u2019s true, and deserves respect. But there\u2019s one small detail here. Why even write everything from scratch? After all, the operating system itself already has default modules that you can simply pull into your application. But this is the company\u2019s policy, and therefore, from their perspective, it\u2019s correct.I\u2019ll give you another example. When I first started developing my messenger, I needed to implement video calls over the P2P protocol. The first thing I looked at was WebRTC technology, as it seemed the ideal solution for video communication. But when I saw the size of this SDK, I was horrified \u2013 the raw size was almost 50 megabytes. Even using the stripped version, I still gained an extra 25 megabytes in my package. Even writing my own WebRTC engine in C++ isn\u2019t guaranteed to be any smaller.I chose the path of least resistance and maximum impact. I figured, since the WebRTC engine is built into the Chrome browser on Android, why not connect to it directly? By attaching Chrome to a WebView, I got this beautiful solution\u2026webView.setWebChromeClient(new WebChromeClient() {  @Override  public void onPermissionRequest(final PermissionRequest request) {    runOnUiThread(() -&gt; request.grant(request.getResources()));  }});Next, I initiated a connection to this library through a separate JavaScript class and voila, everything worked without problems:    class CallManager {        constructor(localVideoSelector, remoteVideoSelector) {            this.localVideo = document.querySelector(localVideoSelector);            this.remoteVideo = document.querySelector(remoteVideoSelector);            this.peerConnection = null;            this.localStream = null;            this.remoteStream = null;            this.pendingCandidates = [];            this.config = { iceServers: [{ urls: &#171;stun_address&#187; }] };        }      \/\/&#8230;If you\u2019re a Java programmer, and I\u2019m sure you are, you\u2019ll notice that the package size with this approach will increase by exactly \u201c0\u201d bytes instead of 25-50 megabytes.Here\u2019s a list of installation package sizes (APKs) for various messengers:Telegram\u00a0= 100 \u041c\u0411.WhatsApp\u00a0= 112 \u041c\u0411.Viber\u00a0= 167 \u041c\u0411.Signal\u00a0= 65 \u041c\u0411.Discord\u00a0= 130 \u041c\u0411.Elyon (Accord)\u00a0= 3.5 \u041c\u0411. (developer your humble servant)With a total app size of 3.5 megabytes, I managed to squeeze in not only video calls but even my own crypto economy. Furthermore, I also implemented a full-fledged messenger with private channels, &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-485721","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/485721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=485721"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/485721\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=485721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=485721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=485721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}