Why is the telegram bot good? It’s handy, you can check for updates from your phone or computer and do various useful things.
Why are decentralized applications good? They live on the blockchain, they do not require an authority to trust, but they are reliable enough to work with finances because of the powerful cryptography. But this cryptography requires complex interfaces, signing on every call in a metamask or on a tiny ledger screen.
Is it possible to manage funds inside the messenger, launch smart contracts with one touch, perform operations and pay small fractions of a cent as fees, and keep your account private keys safe?
Yes, if you are using a NEAR blockchain.
NEAR has the unique feature to create limited functional access keys within your account. For Tip Bot, I wrote a smart contract which is accepting deposits, sending tokens as tips for valuable messages, and finally withdraw tips to the blockchain account. Bot generates a key in order to link the bot to your NEAR account and this key will be able to perform calls only for this specific contract, it will not be able to call any other contract and access your tokens. The key is under your controls and you can remove it from your NEAR account at any time. But as long as key is active, it will allow the telegram bot to send tips in the most simple a way as possible within the messenger.
We can send a tip to the user without even knowing his blockchain address, the tip will be able to accumulate and will be assigned to user’s telegram account. And as soon as user logs into the bot, he will receive a request to connect his blockchain account and withdraw tokens. If user doesn’t have a NEAR account, then bot will create a linkdrop that will lead to the account generation screen, it will cover a small storage fees, and new account will be immediately credited with the remaining tips.
How can we add a bot to the chat? He have to invite it there as a regular user, so it will be able to read and write. And this action will immediately transform the chat into an interface of a decentralized application, where everyone can receive a reward in NEAR tokens for the useful messages.
What shall I do if I you want to send a tip:
1. Go to the web site, log in with your NEAR account and deposit few tokens to the app. You will be able to tip these tokens in the chat later on.
2. Go to the @nearup_bot and log into your account with the /loginTipBot command. You will see a link to the NEAR web wallet. Make sure this access will not be able to spend tokens and call methods of other contracts. Click Authorize.
3. Come back to the bot and enter the name of your NEAR account used in the previous step. Accounts are connected now.
4. Go to telegram chat with bot, for example to @nearforce and send a reply to the message /near N you want to reward (e.g. /near 1 or /near 0.5). A smart contract will change the data in the blockchain every time.
What shall you do if you got tips with the NEAR Tip Bot:
1. Go to the @nearup_bot and check the available balance onchain with the command /mytips.
2. If we have a NEAR account, then just log into the bot using steps 2–3 from the previous list and perform /withdraw.
3. If we don’t have a NEAR account, then call /withdrawLinkDrop and you will get link to generate an account, and it balance will contain all your tips.
- Telegram @nearup_bot. Tip features menu: /tipBot
- Contract is open source: https://github.com/zavodil/tipbot
- All tips and operations are visible in the blockchain: https://explorer.mainnet.near.org/accounts/tipbot.app.near
- Original text in Russian bit.ly/37kxgeH