Reputation: 41
I'm trying create a simple NFT using Java Spring Boot with Web3J dependency. When I'm trying to generate the .abi
file and .bin
file using Solc compiler, I'm receiving this error:
Source "@openzeppelin/contracts/token/ERC721/ERC721.sol" not found: File not found. Searched the following locations: "".
--> src/main/resources/solidity/nfts/SimpleCollectible.sol:7:1:
|
7 | import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The message for this error is clear, I cannot import external file. How I could fix this without copying the required files into my project?
I am new in this topic and I want to integrate smart contracts with Java.
Upvotes: 3
Views: 1321
Reputation: 49661
Normally your ide might have an option similar to this in vscode Package Default Dependencies Contracts Directory
. if this configured successfully, import statement should automatically go inside node_modules
and find the @openzeppeling
dependency. If not you have to pass relative path in solidity code:
import "../node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol";
Upvotes: 0
Reputation: 11
I am also facing the same Error I found one solution for this, but it also has some issues. After compiling it give abi and bin files for both contracts.
You can try this, Add an openzeppelin
file path also in your command.
solcjs ./node_modules/@openzeppelin/contracts/utils/math/SafeMath.sol
./src/main/resources/solidity/AddressBook.sol --bin --abi --optimize -o
./src/main/resources/out
-- The first path is the openzeppelin
contract path and the second is the source file path.
Upvotes: 1