When installing EthPM packages, an installed_contracts directory is created if it doesn't exist. This directory can be treated in a manner similar to the node_modules directory.
Installing a package from EthPM is nearly as easy as installing a package via NPM. You can simply run the following command:
truffle install <package name>
You can also install a package at a specific version:
truffle install <package name>@<version>
Like NPM, EthPM versions follow semver. Your project can also define an ethpm.json file, which is similar to package.json for npm packages. To install all dependencies listed in the ethpm.json file, run the following:
truffle install
An example ethpm.json file looks like this:
{
"package_name": "adder",
"version": "0.0.3",
"description": "Simple contract to add two numbers",
"authors": [
"Tim Coulter <tim.coulter@consensys.net>"
],
"keywords": [
"ethereum",
"addition"
],
"dependencies": {
"owned": "^0.0.1"
},
"license": "MIT"
}
Creating and publishing an npm package for truffle is the same process as creating any other npm package. To learn how to create and publish an ethpm package, visit http://truffleframework.com/docs/getting_started/packages-ethpm#publishing-your-own-package. Regardless of whether you are publishing your package as an npm package or ethpm package, you need to run the truffle networks --clean command. When this command is run, it deletes artifacts for all those networks IDs that match only the * wildcard character in the configuration file. This is done as these addresses will be invalid for the other projects consuming this package, as these networks are most likely to be private as they are used for development purpose only. You shouldn't omit this command unless you know what you are doing. It will fail to delete any artifacts for private networks listed as a constant, so you need to delete them manually.