This is my first blockchain project. I'm still a newbie to it. Although I'd been longing to learn more about blockchain before this but there was nowhere for me to start with as I've never invested in any cryptos nor touched any blockchain-related technologies.

First of all thanks to a friend of mine who came to chatting with me about cryptos & blockchain technologies on WhatsApp in late August 2021. He introduced a number of blockchain technologies to me, especially about Solana for its superb speed and showing me a number of those Defi apps built on Solana and the need to use Rust lang to program its smart contracts etc.

And then he asked me if I could code some dApps or program in Rust for Solana as there could be some opportunities as he himself isn't a coder nor a technical person. But I told him I was completely new to it and knowing nothing about it but I'd love to learn from scratch especially with Rust programming.

Therefore I started to learn the Rust lang and we started chatting about what could be built or something different from what's already there. Then an idea of mutual fund came up. And I was thinking it'd be cool - whether you're an expert or you're just a starter who wants to learn investing in cryptos, DEX and you don't have much fund yet you can have your own fund pools and raise funds from your friends & families etc. Or if you're an expert you can manage funds and make profit for them too...

And it happened that in mid of September, I received an email from DevPost about this hackathon, therefore I took the opportunity to take part in it mainly for research & learning purposes.

What it does

The project is called Solfund. It's a mutual fund platform and a complete serverless dApp that works on the Solana blockchain, all data stored on chain.

Anyone with a SOL wallet can become fund manager, create & manage fund pools and invite their family members, friends, relatives or followers to invest in their pools. And anyone connected with a SOL wallet can invest in those fund pools and let their fund managers manage their funds and earn for them by investing in cryptos, DEX, lending etc. And It requires NO personal data, all you need is just connect your wallet.

When a fund manager creates a fund pool, he or she needs to specify the total number of tokens the pool is going to generate or mint and the token to SOL ratio (which means how much in SOL a token is worth). And the manager can choose to add commission in SOL to charge for the transactions.

An investor is investing in a pool by buying the tokens and pay with SOL. The number of tokens an investor holds represents his or her share in the pool.

Fund invested by investors will go the escrow account of the pool, which the fund manager can only utilize for investments in cryptos, DEX, lending etc to make profit for the pool. Only investors have shares can withdraw from it.

How I built it

I developed the on-chain program/smart contract with Rust lang and the front-end web UI with React/TypeScript with a number of helper frameworks & UI library including Solana web3 JS, Solana Wallet adapter, AntDesign, react-share etc.

Challenges I ran into

Coming from a background of Swift (native iOS), Java, PHP & JS (mostly on the old jQuery framework), it took me longer than expected to learn TypeScript/React & Rust lang. But I had great fun with them, started loving them.

And it took me longer than expected to understand the concept of decentralized apps since I've been developing centralized apps based on relational database technologies such as MySQL, Oracle for many years.

And It took me longer than expected to search for information, read and understand how the Solana blockchain works, such as how an account needs to be created for storing data on the Solona blockchain, and accounts need to be passed from the client side to the Rust on-chain programs and how to pack and unpack its data in different sizes of byte arrays for different data types etc (I could have used the Serum's Anchor framework which I discovered later but I was already half way through it, therefore I didn't opt to use the Anchor framework). And having to read and figure out a number of TypeScript/Rust GitHub repos of Solana.

And it also took me quite some times to figure out and understand on how to use the associated token account for SPL token & account creation, minting, the PDA & escrow account etc.

It was a complete "code and learn along the way" and information/terminology was overwhelming for someone like me who's new to it. The Discord channels did help some but there was a need to write some small unit testing code to verify and understand them.

Accomplishments that I'm proud of

Managed to build a platform, a complete serverless dApp from scratch that stores data & works on the Solana blockchain (currently on devnet only). The platform currently consists of the market, the user's pool which indexes and stores the data of the fund pools, the investors' transactions on chain.

Managed to build the features including allowing anyone connected with a SOL wallet to create fund pools and generate the tokens. And investors connected with SOL wallet can invest fund by buying tokens in SOL from any pool in the market and the fund goes to the escrow account of the pool.

And of course, the project isn't finished, I'll continue my research and development how to achieve the rest of the features & the final product.

What I learned

I learned a lot including setting up solana, the cli, spl tokens, Rust programming, deploying the program on devnet, TypeScript/React, & React hooks, AntDesign etc and how to build web3/dApps on blockchain...

What's next for Solfund

  • Research & development for the module that fund manager can utilize the escrow fund to invest in DEX, buy cryptos or lending to others for generating profit for the pools etc.
  • Research & development for the module, the smart contracts/on-chain programs to govern only share holders are allowed to withdraw funds etc.
  • Research & development for the possibility of integration of existing Solana services, such as Serum DEX, Solend, Raydium etc
  • Improve UI, gamify it, making it more user-friendly and bring it to the mainnet
  • And also research the possibility to develop native mobile versions for it.

Built With

Share this project: