web3 icon indicating copy to clipboard operation
web3 copied to clipboard

Cannot build.

Open 621625 opened this issue 4 years ago • 12 comments

Hello,

I'm MB. A very nice and polite guy.

This is my contract:

// SPDX-License-Identifier: MIT pragma solidity 0.8.0;

import "https://github.com/0xcert/ethereum-erc721/src /contracts/tokens/nf-token-metadata.sol"; import "https://github.com/0xcert/ethereum-erc721/src /contracts/ownership/ownable.sol";

contract newNFT is NFTokenMetadata, Ownable {

constructor() { nftName = "Synth NFT"; nftSymbol = "SYN"; }

function mint(address _to, uint256 _tokenId, string calldata _uri) external onlyOwner { super._mint(_to, _tokenId); super._setTokenUri(_tokenId, _uri); }

}

When I try to build using this command:

web3 contract build nft.sol

I get this error message:

ERROR: Cannot generate flattened file: read ./.: is a directory

621625 avatar Oct 28 '21 05:10 621625

No matter what I type, I don't get a bin file.

621625 avatar Oct 28 '21 05:10 621625

What OS are you using?

treeder avatar Oct 28 '21 18:10 treeder

@bitcoinmeetups github imports are not supported in web3, please download it locally (clone) and import as local files

r-gochain avatar Dec 28 '21 08:12 r-gochain

He's talking about these imports: import "https://github.com/0xcert/ethereum-erc721/src /contracts/tokens/nf-token-metadata.sol";

@r-gochain why wouldn't it support that if it's part of solidity now?

https://docs.soliditylang.org/en/v0.8.10/path-resolution.html

treeder avatar Dec 28 '21 17:12 treeder

@treeder sure, let me check if we can support that in web3 (improve flattening algorithm or maybe just pass to solidity compiler as is)

r-gochain avatar Dec 29 '21 15:12 r-gochain

Or maybe we don't flatten and just let solc do it's thing? I know it's nice to see the flattened file for verification and things, but if solc handles it, why not just use it?

treeder avatar Dec 29 '21 16:12 treeder

Yes, I'm going to check whichever is easier

r-gochain avatar Dec 29 '21 16:12 r-gochain

hmmm, so solc doesn't support these type of imports (latest version)

image

r-gochain avatar Dec 30 '21 09:12 r-gochain

so - https://docs.soliditylang.org/en/latest/layout-of-source-files.html#import-paths

r-gochain avatar Dec 30 '21 09:12 r-gochain

solcjs doesn't work either, seems like there are only 2 options

  • remix-ide - https://remix-ide.readthedocs.io/en/latest/import.html (no command line options)
  • custom implementation

r-gochain avatar Dec 30 '21 11:12 r-gochain

https://github.com/ethereum/remix-project/blob/b52433aa7e123691481c9390dc504554a671f5c1/libs/remix-url-resolver/src/resolve.ts#L42-L74

r-gochain avatar Dec 30 '21 11:12 r-gochain

Ahh, I see, didn't realize that was remix only.

treeder avatar Jan 04 '22 13:01 treeder