TL, DR This article explains how one can buy and sell cryptocurrencies to any (Unified payment interface) UPI .
Anyone in India who has used an online payment system like GPay , PhonePe , Paytm sure can appreciate the sophistication and the ease of system . The role of such payment systems was crucial in helping small businesses transcat locally as well as globally for the digital world .
What if such a system existed for cryptocurrencies where one can seamless buy and sell any crypto currencies ? .
As of this writing the only way to buy cryptocurrencies in India is to register yourself on exchanges like WazirX , Zebpay , complete the kyc and exchange the fiat currency for crypto.
But what if one needs crypto on the go ?
This article proposes such a system built on top of the UPI , so that users can buy and sell cryptocurrencies instantly without any kyc . All one needs is a upi id and a wallet for the
corresponding cryptocurrency .
Before we proceed let's check the entities involved in the project :
1 . Smart Contract : For Interacting with user’s crypto wallet
2 . User application : Interface for user
3 . Application endpoint that interacts with a bank and smart contract .
Please refer the following diagram to understand the flow of the application :
1 . Buying a cryptocurrency
(Follow the arrows with red label)
1. User enters his upi id , cryptocurrency of the choice , wallet address for the same , ,amount and makes the request .
2. Request reaches the buy endpoint which inturn makes request to users upi wallet to proceed further with the transaction .
3. User approves the fiat transaction and pays the amount he entered in fiat , confirmation is sent again to the buy end point .
4. Buy endpoint receives the confirmation and sends a request to contract buy end point specifying amount to crypto currency to be transferred to the users crypto wallet .
5. Smart Contract receives the request and transfers the crypto assets to users’s wallet .
2 . Selling a cryptocurrency .
(Follow the arrow with green label)
1. User connects the crypto wallet to the application , enters the cryptocurrency of the choice , amount of crypto he wants to sell , upi account id and makes a request to the endpoint of the smart contract .
2.Smart contract receives the amount and gives confirmation to the application sell endpoint .
3. Sell endpoint receives confirmation and transfers the amount to the user's upi wallet .
Inorder to provide seamless transactions the smart contract as well as the bank account associated with application(which facilitates payouts)must hold significant collateral in order to avoid delayed transactions.
Smart Contracts for ERC-20 tokens can make use of chain link adapters for accepting and issuing requests .