8

I want to use an external library. I guess it is good to load the library in production from a CDN because this requires less space and should be faster.

import "github.com/Arachnid/solidity-stringutils/strings.sol";

But in dev this library cannot be found: Cannot find import strings.sol from Challenge.sol. If it's a relative path, ensure it starts with ./ or ../.

I read in this post: How should we set a import path in solidity?

And in this tutorial: http://solidity.readthedocs.io/en/latest/layout-of-source-files.html

When the compiler is invoked, it is not only possible to specify how to discover the first element of a path, but it is possible to specify path prefix remappings so that e.g. github.com/ethereum/dapp-bin/library is remapped to /usr/local/dapp-bin/library and the compiler will read the files from there.

So I created the folders /usr/local/dapp-bin/library/solidity-stringutils/ and downloaded the github repo to that folder.

I also tried to put it directly into /usr/local/solidity-stringutils/

But I' still getting: Cannot find import strings.sol from Challenge.sol. If it's a relative path, ensure it starts with ./ or ../.

Can I configure truffle that it takes libraries from a default folder. Good would be github.com/*/lib-name => ./vendor/lib-name

  • Have you solved it? – Andrey Feb 27 '18 at 19:20
  • No I stopped working on it – Andi Giga Feb 28 '18 at 7:34
0

AFAIK, such path remappings like available with solc will not be possible with truffle+solcjs right now. See https://github.com/trufflesuite/truffle/issues/613.

There is support for importing from npm modules (see http://truffleframework.com/docs/getting_started/packages-npm), however, it's a different mechanism. It would require wrapping the target library.

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.