CosmJS — The missing piece

Simon Warta
4 min readJun 23, 2020

When I joined Ethan Frey at IOV, he asked me to work on a pretty interesting library project. It was an abstraction for crypto currency handling of very different account based blockchains to power a multi-chain wallet. In about one year we built a set of libraries that

  • connected Tendermint+Weave, Lisk and Ethereum;
  • encoded/decoded/signed transactions;
  • used Ed25519 or Secp256k1 HD keys based on mnemonics which are securely encrypted locally;
  • running in Node.js, all major browsers as well as browser extensions.
Photo by Laura Ockel on Unsplash

IOV Core, how the project was called, reached its 1.0 after a full code audit right before the mainnet launch of the IOV Name Service in October 2019. It then powered faucets, scrapers, address generators, explorers, a wallet and a governance app as well as a browser extension. While at a high level, the library is very specific to IOV’s product, a large foundation was necessary to make it all happen. This foundation is modular, generic and thus highly reusable.

With the emergence of CosmWasm early 2020, we needed a way to connect to Cosmos SDK based blockchains and interact with smart contracts to provide a rich user experience. Given the experience and building blocks from our work at IOV, we created CosmWasm JS in about one month. The codebase was still so aligned with IOV Core that we could integrate smart contract tokens into the multi-chain wallet Neuma.

From CosmWasm JS to CosmJS

As part of our work towards IBC integration into CosmWasm, we’ll need to build lots of powerful client-side tooling, such as an IBC relayer that runs in a browser or light-client proof verification of Tendermint responses. At the same time, Billy from the Interchain Foundation tried to bring the ecosystem together in order to collaborate on a shared client-side library for the Cosmos SDK. We proposed to generalize CosmWasm JS to make it Cosmos specific and turn the CosmWasm part into an optional component. After many talks with product builders in the ecosystem we got the clear feedback that such a generic library would be appreciated, allowing product developers to focus on products instead of re-inventing the wheel once per project. After one week of naming discussion we started the transition to CosmJS, resulting in the first release on npm one week later.

Who’s in?

The CosmWasm team did not only work on code but spent a lot of effort into listening to potential users and collaborators and building trust. Development is just so much more fun when your work is used widely. Those are the initial projects working with us:

  • IOV handed over large chunks of their codebase to us, such that IOV Core is now based on CosmJS.
  • Lunie is planning to utilize CosmJS to power their wallet solution.
  • Chainapsis wants to integrate CosmJS into Keplr and build a standardized signing API for Cosmos blockchains.
  • Cosmostation decided to integrate CosmJS into their Cosmos JS library.
  • Agoric is looking to use it in its projects including JavaScript IBC support.

So far we are focusing on products facing the challenge to sign transactions. Once we have that covered, we’ll open partnering to the most sophisticated query support for explorers and scrapers.

“But I just use package XYZ from npm”

JavaScript is known to be easy to get started with. Part of that comes from the level of abstraction of the language itself, part of it from the ever growing npm ecosystem. For every algorithm you probably find some dude who put an implementation on npm. But maintaining great JavaScript code is hard and involves much more than dumping code that works for me. We strive to maintain production quality software that

  • is developed utilizing a strict type system via TypeScript and an exhaustive set of linting rules, avoiding most of the surprises JavaScript has to offer;
  • heavily tests every API using external test vectors, ensuring that our dependencies work as expected and don’t break along the way;
  • spawns real blockchains as part of the CI process to test integration;
  • runs tests natively in Node.js and browsers;
  • provides a consistent modern API with automated doc generation;
  • has been audited and should be again on a regular basis.

Roadmap

If your project works today, we’re here to support it with reliable components. But our strategy goes far beyond that. We want to allow you to create the most capable clients possible, that do not rely on external services to perform operation XY for them. Next up:

  1. Protobuf transaction encoding and signing support coming with Cosmos SDK 0.39;
  2. Support for custom message types and custom blockchain modules;
  3. Direct connectivity to the Tendermint RPC endpoint, allowing the use of more advanced filters, subscriptions and light-client proof verification;
  4. IBC support, e.g. relayer as a library.

The complete and curated roadmap is available in this Trello board.

Getting involved

First and foremost, CosmJS is free as in freedom, hosted on Github. Check it out, see what it can do for you already and use issues and pull requests to contribute. The primary communication channel from now on will be #cosmjs on the “Cosmos Community” Discord server. The CosmWasm team maintains the project for the foreseeable future but we also would love to see multiple teams contributing to the codebase once things have stabilized.

Kudos

This project would not have been possible in this open fashion without the ICF’s moral and financial support. We’re grateful to be given the chance to share a great product with a wider audience. Thank you to all the product builders who trust us to build the foundation for their products. And last but not least a big shout-out to IOV for laying the groundwork, allowing us to ship great code in a very short amount of time.

--

--

Simon Warta

Building CosmWasm and CosmJS at Confio | Ex IOV | Co-Founder of Kullo | Board member prolina Foundation