[Ethereum] How to import from / install OpenZeppelin properly

importmistopenzeppelintruffle

I'm a newb dev and want to play with smart contracts, and was trying to figure this out. Ive installed truffle and openzeppelin, everything seems to check out, but in Mist I still get an error when I try to import Math.sol saying it can't be found, what do I do?

Best Answer

Here are the full steps starting from a blank truffle project. You could replace truffle init with truffle unbox <package> if you want to start from a Truffle box.

  1. Create a new directory
  2. truffle init: initialize truffle in the directory
  3. truffle install zeppelin: install open-zeppelin using ETH Package Manager

A new folder will be created called installed_contracts which contains all the files.

You can import the Math.sol library by adding this line in your contract in the contracts folder:

import "installed_contracts/zeppelin/contracts/math/Math.sol";
Related Topic