13

I am trying out Remix as an IDE. However, I'm using the excellent open-zeppelin library for development. Is there any way to include all the files from open-zeppelin in the build path for Remix without pasting them all in there?

I have tried importing a local directory, but since my normal build tool is Truffle, the Remix compiler doesn't pick up the node_modules directory. I tried copying the open-zeppelin directory into the contracts directory, but still my imports won't work. They work if I prefix my paths "./", but I'd rather not do that, since I would have to do it in every single open-zeppelin file.

10

The easiest is to use remixd to share your build directory with remix. Here are indication how to configure it Accessing a shared folder in Remix IDE using Remixd.

Another option is to use the remix feature that allows importing directly from github, so you do not need the openzeppelin files.

pragma solidity ^0.4.15;

import "github.com/OpenZeppelin/zeppelin-solidity/contracts/ownership/Ownable.sol";

contract BasicToken is Ownable {
    function () public payable {
    }

    function withdraw(uint amount) public {
        if (amount <= this.balance) {
            msg.sender.transfer(amount);
        }
    }
}
| improve this answer | |
  • 3
    I'm using a shared folder with remixd. The point is, I don't want to rewrite all my import statements in order to be able to work in Remix. My code (and the zeppelin code) already contains import statements of the type import "zeppelin-solidity/contracts/crowdsale/CappedCrowdsale.sol";. I'd like the import statements to stay that way. – karianneberg Nov 28 '17 at 9:20
  • URL is dead unfortunately – Emobe Dec 31 '19 at 12:25
  • @Emobe Remix has changed a lot from two years ago. The new URL seems to be remix-ide.readthedocs.io/en/latest/remixd.html. – Ismael Jan 1 at 2:16
3

Have you tried Patricio Palladino's truffle-flattener?

Truffle Flattener concats solidity files developed under Truffle with all of their dependencies.

This tool helps you to verify contracts developed with Truffle on Etherscan, or debugging them on Remix, by merging your files and their dependencies in the right order.

| improve this answer | |
1

Yes it's possible just use:

pragma solidity ^0.4.24;

import "https://github.com/OpenZeppelin/openzeppelin-solidity/contracts/ownership/Ownable.sol";

contract SimpleContract is Ownable {

}

The package zeppelin-solidity mentioned above is deprecated

| improve this answer | |
  • Problem is the openzeppelin-solidity contracts import other ones and they don't use the github link. This is not a correct answer. – M H Apr 17 '19 at 2:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.