0

This is the LSP3Account contract: https://github.com/lukso-network/standards-implementations/blob/master/contracts/Accounts/LSP3Account.sol

I want to create a contract on Remix that inherits from it. I tried this:

pragma solidity ^0.6.0;

import "https://github.com/lukso-network/standards-implementations/blob/master/contracts/Accounts/LSP3Account.sol";

contract MyProfile is LSP3Account(msg.sender) {
    
}

But this results in: not found @openzeppelin/contracts/introspection/ERC165.sol

So I copied and pasted the entire LSP3Account.sol contract in Remix, to try to fix the imports manually.

I figured once these imports were fixed, I would finally be able to inherit from the LSP3Account contract.

However, when I fixed the ERC165.sol import, another import error showed up (UniversalReceiverDelegate.sol).

Once I fixed that, another import error showed up (UniversalReceiver.sol). I fixed that too.

But my imports started getting out of hand. Here's the top of my file. I used OLD and NEW to mark the fixed imports:

pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;

// interfaces
//import "../_LSPs/ILSP1_UniversalReceiver.sol"; OLD 3
import "https://github.com/lukso-network/standards-implementations/blob/master/contracts/_LSPs/ILSP1_UniversalReceiver.sol"; // NEW 3
//import "../_LSPs/ILSP1_UniversalReceiverDelegate.sol"; OLD 2
import "https://github.com/lukso-network/standards-implementations/blob/master/contracts/_LSPs/ILSP1_UniversalReceiverDelegate.sol"; // NEW 2

// modules
import "erc725/contracts/ERC725/ERC725Account.sol";
//import "@openzeppelin/contracts/introspection/ERC165.sol"; OLD 1
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v3.x/contracts/introspection/ERC165.sol"; // NEW 1

contract LSP3Account is ERC165, ERC725Account, ILSP1 {

But guess what, now I get the error: not found @openzeppelin/contracts/cryptography/ECDSA.sol

This new import error isn't even from the LSP3Account contract. It's from one of the contracts it inherits from.

The only solution I see, would be to copy and paste the entire inheritance tree, and fix the imports from the bottom-up. But this seems ridiculously complicated.

I also know I can clone the project locally, run npm install, and all the dependencies will be installed. But:

  1. I ran into problems because the dependencies have different compiler versions.
  2. It's much easier to deploy from Remix, rather than deploy from local files.

So a couple of questions:

1. Can I cancel imports from contracts my contract is inheriting from?

2. More importantly, isn't there a way to simplify these inheritance and import problems on the Remix IDE?

0

No, you can't avoid inherited imports because the contract you are inheriting from needs it.

You have to import every single package that is needed for every single contract to work.

@openzeppelin/contracts/cryptography/ECDSA.sol This kind of syntax is used to import local packages, but since there are no local packages in remix, you have to use the full path to GitHub, you already did that here:

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v3.x/contracts/introspection/ERC165.sol"; 

Another way to import is just copy-pasting every dependency into your folder, so it will be importable with './' syntax, but that will make your workplace a bit messy, and honestly, using GitHub paths is a way easier and cleaner way to do so.

For the record, I highly advise using truffle/hardhat, might be a bit difficult than remix but for serious projects, it's very useful in many ways, especially for unit testing, and also, managing dependencies is easier.

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.