ethpm: npm for the Ethereum / Solidity ecosystem !

Every JavaScript developer knows and uses npm : it is the de-facto package manager for JavaScript. Long are the days when you'd use some JavaScript package by using

<script src="www.somecdn.com/script.js"></script>

Except maybe if you use jQuery. Which, at this point, would probably be bigger of an issue than using script tags ;).

Not only does npm make using packages a breeze, but it also reduces bugs(no vars i.e variables in the global scope), and has a few other advantages over the old script tag way of using external code.

Ethereum, on the other hand, is very young. It doesn't have the mature ecosystem JS has, although it seems to be evolving very quickly thanks to the work of the Ethereum team, as well as companies like Consensys (Metamask, Truffle), that are well set on creating the standards and good practices of this very new field.

As such, a standard exists for Solidity packages management: ethpm

npm-like syntax

If you've used npm (or pip for Python, Composer for PHP..) you know how to use the ethpm implementation from Truffle. Because yes, ethpm is a spec ERC190 of the Ethereum protocol, as such, there are different implementations. Think of it as Flux (the idea) and Redux(one of many implementations).

To install a Solidity package in your current project, just run :

$ truffle install <package name> --save // to update the ethpm.json file

And that's it ! Your ethpm.json file (similar to package.json) will be updated, so other developers can pull your repo and just run

$ truffle install 

Similar to npm install, this will install all of the dependencies from the ethpm.json file.

js-like imports

As with js/npm, consuming Solidity contracts installed with Truffle (or any other tool following the ERC190 standard) is done as easily as

import "owned/owned.sol";

Easy ! Your dependencies will be available in a installed_contracts file, which is the equivalent of node_modules.

As usual, congratulations to the Truffle team for developping such incredible tooling for Solidity, but also the Ethereum team and contributors for their reactivity on the creation of new specs. Solidity and Ethereum are quite new still, but I feel like standard and good practices are being found very quickly thanks to their work.

👏