Solana India Fellowship - Week
This post is a part of a series of posts documenting my experience as a fellow in the Solana India Fellowship. You can find other posts in this series here.
The weekly talk was by Preethi Kasireddy, on how to transition from web2 to web3 development, and it was a good overview on how to think about blockchain programming, security, building community, and of course, memes.
Some thoughts on Solana development
The exercise for this week was re-implementing an ETH voting/delegation contract on solana. On the EVM, this is easy as you can store all the data in global variables on-chain in the same contract and update them as necessary.
However in Solana, all programs are stateless and you have to provide a list of all accounts you are going to use/modify in advance. This makes it so that you have to often re-think your code architecture, as the most straightforward way to write your code usually won’t work in the stateless model.
This often leads to a lot of setup code and a lot of client side code, whereas in solidity, the majority of the code is on-chain and only function calls and arguments are passed via the client.
This is a general pattern in Solana development, the trade-off for speed of execution and extremely cheap fees is that the system is much more complicated to reason about. In general, I think this trade-off is worth it even considering the significant loss in developer productivity.
Also, a lot of the complexity can be hidden by frameworks such as Anchor, however it is helpful to fully understand the low level details first as it makes debugging programs a lot easier.
Buy Now Pay Later with Solana Pay
Solana pay is simply a URL specification and does not have any special on-chain footprint. If I have a bunch of SPL tokens in my wallet, I cannot make payments using Solana Pay unless the merchant specifically programmed that SPL token as a payment option
I spent some time this week building a BNPL financing protocol on top of Solana Pay.
Some things I want to build towards:
- Instant payment to merchant in USDC, the on-chain program should take on any price/volatility risk.
- The user can lock in any SPL token as collateral, and gets to choose a fixed payment term.
- The interest rate is variable and calculated every epoch.
- Collateral is freed incrementally as the user repays his obligation.
- If the payment term expires, any remaining locked collateral is liquidated.
For the backend, creating another DeFi lending clone just for this didn’t make much sense, it will be more efficient to use any one of the dozen or so lending protocols live on mainnet. This way we also get the advantage of low interest rates from already established liquidity pools.
I have built out a very tiny prototype for this and am currently fleshing out a few details. Stay tuned for more details next week.