A Cosmos Wallet inside MetaMask using Snaps.

The problem Cosmostic solves

MetaMask is arguably the most popular browser wallet in the market right now. It is used by hundreds of thousands of developers worldwide, and I was one of them. However, it lacked compatibility for the Cosmos ecosystem, which is non-EVM compatible. Being a Cosmos developer, this was a barrier to the accessibility of MetaMask for users worldwide, hence considering the booming growth of the Cosmos ecosystem along with the popularity of MetaMask, I thought that I can solve this accessibility challenge by building a snap for MetaMask that would allow dApps and users to interact with their own Cosmos account, similar to interactions with EVM accounts. This would be a gamechanger for Cosmos developers and MetaMask users worldwide, because Cosmos developers would be able to leverage the awesome functionalities of MetaMask while working in Cosmos ecosystem, and MetaMask users would be able to access Cosmos dApps without installing different wallets and maintaining them. I was truly able to kill two birds with one stone.

Challenges I ran into

I faced many challenges while building this project, and in order to resolve those challenges, I researched into possible solutions, errors and techniques. The first major challenge I faced was generating a cosmos-compatible bech32 address. The initial version of the snap was supposed to work with ATOM and Cosmohub, however, I was unable to find resources for generating those addresses, and the signed verification of the address was invalid, everytime I tried. So I switched to Cudos, and used the


library to fix the issue. After hours of work, going back and forth between code, the issue was resolved. The next funcionality I was implementing was signing raw messages. This time, just like the previous time, I was unable to find appropriate resources for signing messages. The snaps environment kept on returning errors without proper stacktrace. This was not only a time-consuming issue but also an annoying one, as I had to guess from the context of the code. After hours of debugging, I found the issue in the signing library I used. I replaced the signing libraries, one after the other, but none worked, until one library resolved the issue, and messages were signed. The last issue was in transferring tokens from one account to another. The solution to this bug was simple, however it took me an embarrasing amount of time to figure it out. Once these hurdles were crossed, all the components of the snap fell in place, and the snap worked beautifully.