Securely store and retrieve encrypted data on the Avail blockchain using a Telegram bot. Built with NestJS, Lit Protocol for encryption, and Polkadot.js for blockchain interactions. Simple, decentralized, and user-friendly! 🚀🔒📱 #Blockchain #TelegramBot
Prize Pool
Prize Pool
This project is a backend service that facilitates interaction between users and the Avail blockchain via a Telegram bot. The main functionality of the service allows users to securely submit and retrieve encrypted data on the blockchain. Using Lit Protocol for encryption and decryption, the project ensures that data remains private and secure throughout the process.
Users interact with the system through a Telegram bot, where they can submit data, encrypted with a public key, which is then stored on the Avail blockchain. Additionally, users can retrieve stored data by providing a transaction hash and decrypt it using their private key. The project integrates Polkadot.js API for communicating with the Avail network and leverages NestJS for the backend structure.
Key features include secure data handling, blockchain-based storage, and retrieval, making this project a powerful tool for decentralized applications that require secure and reliable data management.
This project was built using a combination of cutting-edge technologies to securely handle data submission and retrieval on the Avail blockchain, all orchestrated through a Telegram bot interface. Here's a breakdown of the key components and how they work together:
Backend Framework: NestJS
The core of the project is powered by NestJS, a progressive Node.js framework. NestJS was chosen for its modularity, scalability, and support for TypeScript. It helped structure the backend service efficiently, allowing for easy integration with external APIs and services.
Blockchain Integration: Avail Blockchain & Polkadot.js API
To interact with the Avail blockchain, we utilized the Polkadot.js API. This library enabled us to easily connect to Avail’s decentralized network, submit transactions, and query data from the chain. Specifically, we implemented functionality to: Submit data using Avail's dataAvailability.submitData function. Retrieve stored data from the blockchain using transaction hashes.
Data Encryption & Decryption: Lit Protocol
Lit Protocol was integrated to handle encryption and decryption of the user-submitted data. This ensures that any data stored on the blockchain is encrypted using public keys, and only authorized users with the corresponding private key can decrypt it. Key encryption flow: Users provide a public key to encrypt their data before submitting it. Data is encrypted on the client side using Lit Protocol. When retrieving data, users provide their private key to decrypt the data after pulling it from the Avail blockchain.
Telegram Bot: node-telegram-bot-api
We used the node-telegram-bot-api library to create an interface where users can easily interact with the system through Telegram. The bot allows users to: Submit data by providing their public key. Retrieve stored data by providing the transaction hash and decrypt it using their private key. This Telegram-based interaction provides a simple and familiar interface for users to interact with the blockchain without needing technical expertise.
Hacky Workarounds & Challenges
One of the hacky parts of the project was managing asynchronous transaction submissions on the blockchain while maintaining real-time interaction via the Telegram bot. Handling transaction states, including errors or blockchain rejections, and relaying that information back to the user in real-time through the bot required careful handling of async operations and error management. We also had to implement a secure key management system for users to submit their public and private keys in a way that ensured the integrity of the encryption process and prevented any leaks or mishandling of sensitive information.
Partner Technologies
Lit Protocol was a key partner technology, enabling secure encryption and decryption of data without needing to expose private keys or secrets during the submission or retrieval process. Avail blockchain allowed for the decentralized, tamper-proof storage of data, ensuring the integrity and availability of information.
By combining these technologies, the project provides a secure and decentralized way to store and retrieve data on the blockchain, all through an easy-to-use Telegram interface.