2

I am trying to reference mortal.sol in the standard ethereum library. I have deployed mortal.sol under my main test account. However I get the error source not found. What I tried was:

import "https://github.com/ethereum/solidity/blob/develop/std/mortal.sol"

Then I have a contract set up like:

contract foo is mortal {

somestuff; }

what do I need to do to reference a Mortal contract that is deployed already on the chain?

I have looked at some posts but cannot seem to figure out. Any ideas?

Thanks!

2

You cannot import a remote dependency into your local contract. You can remap the reference to a local directory, but you still need to clone the dependent contracts in order to compile your contract.

From the Solidity docs:

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 as an example, if you clone github.com/ethereum/dapp-bin/ locally to /usr/local/dapp-bin, you can use the following in your source file:

import "github.com/ethereum/dapp-bin/library/iterable_mapping.sol" as it_mapping;

and then run the compiler as

solc github.com/ethereum/dapp-bin/=/usr/local/dapp-bin/ source.sol

| improve this answer | |
0

Thanks for the answer. but I have been using the Solidity compiler in the Ethereum Wallet UI. I was able to solve the problem by using the post:

How to deploy dependent contracts with Ethereum Wallet

Basically, I pasted the code I wanted to compile including the contract Mortal that I had already deployed but did not deploy Mortal again.

| improve this answer | |

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.