A lot of my non crypto friends are interested in crypto, some even hodl crypto on an exchange, even ETH. But DeFi? That's a step to far. The purpose of this hack is to give light to the idea that we should use the most intuitive interface known to our generation as an entry into DeFi and Ethereum, over 4 billion people are using the messaging interface, it's intuitive and engaging. This hack is mainly a fork of the official Telegram Android app (Telegram Totality, in short: tg-total), tg-total is indistinguishable from the official Telegram Android app, you are still able to send to and receive messages from all contacts. Well, it’s indistinguishable except for the fact that tg-total contains an integrated non-custodial Ethereum wallet. The following features are implemented Store private and public key View DAI balance in menu Tip button (1 DAI) for users that have their public address in their bio Bot protocol, enables intuitive in-chat Ethereum transactions ENS example Aave example The storage of the private key is necessary for every other functionality to work, the DAI balance and tip button are fun add-ons. But the bot protocol is the most interesting aspect of the hack. In my opinion it gives the best ethereum user experience possible and still fulfills the requirements of decentralization. For example, if you get liquidated on Aave, it is a harsh event. Not everyone is monitoring their position constantly and the incident of huge drops in price of collateral is not unthinkable. The bot I created monitors your Aave health factor and sends you a message if your health factor gets below a certain threshold. This functionality is available for every Telegram user. But if you use the tg-total client, you are able to deposit ETH or DAI to increase your health factor from the chat. (https://github.com/Evert0x/AaveBot) Another example is the renewal of ENS domains. For a lot of ENS domains it is time for renewal or the current owners will lose them. Most users probably are not actively monitoring their domain names, maybe they want to keep the domain name, but are not under the impression that action is required. The bot I created collects your registered `.ens` domain names and send you a message when they are about to expire. This functionality is also available for every Telegram user. But if you use tg-total, you are able to renew your domain name from the chat. (https://github.com/Evert0x/ENSbot)
How It's Made
The Telegram Android app is open source on Github, I created a fork and started to get myself familiar with the code. My first goal was to integrate the private key storage. In this hackathon version you are not able to generate a key pair and you have to insert your raw private key. Not the best practice, but the purpose of this hack is to inspire people to look more at the possibilities within chat/telegram. ## Dependencies The extra dependency for tg-total is Web3j, because the app is created in Java. I use it for every Ethereum specific interaction, I also used it to generate java classes for Aave and ENS based on the abi of the contracts. The Telegram bots are created with python and the python-telegram-bot package, it is a great wrapper around the telegram bot api. For ethereum specific action, like getting all ENS domains and getting the Aave health factor, I use Web3py. ## Protocol In the hack, only the ENS and Aave use cases are supported. If these bots create an inline button, the `callback_data` field is parsed to see if it matches a contract call The following links highlight the place in the code. https://core.telegram.org/bots/api#inlinekeyboardbutton https://github.com/Evert0x/Telegram/blob/master/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java#L5770 https://github.com/Evert0x/AaveBot/blob/master/workers/montor_health.py#L35 If the `callback_data` matches a contract call, the contract is called and the transaction hash is passed to the bot that initiated the call. https://github.com/Evert0x/ENSbot/blob/master/server.py#L9 ‘Normal’ clients are also able to click this button, the Telegram protocol is still intact. But only tg-total client will send the transaction hash to the bot. The bot waits for the 2 calls to come in (The Telegram callback and the transaction hash), in one is missing, The tg-total client is not used. You can verify this flow by talking to @EasyENS_bot with a normal Telegram client.