2

When I run the following to deploy my contract with foundry

source .env
forge script script/CryptoDevs.s.sol:CryptoDevsScript --rpc-url $GOERLI_RPC_URL  --private-key $GOERLI_PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_API_KEY -vvvv

I get this error

Compiler run failed
error[6275]: ParserError: Source "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol" not found

Even though I fixed vs code warning like this @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol not found: File import callback not supported

with a .vscode/settings.json file

{
    "editor.formatOnSave": true,
    "solidity.formatter": "prettier",
    "solidity.defaultCompiler": "remote",
    "solidity.compileUsingRemoteVersion" : "latest",
    "solidity.packageDefaultDependenciesContractsDirectory": "src",
    "solidity.packageDefaultDependenciesDirectory": "lib",
    "git.ignoreLimitWarning": true,
    "solidity.remappings": [
        "@openzeppelin/=lib/openzeppelin-contracts/",
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "forge-std/=lib/forge-std/src/"
      ],
}

I still get the error. What do I miss?

1 Answer 1

2

Vs Code and Foundry are different pair of shoes

You need to add additionally a remappings.txt file at the root of the foundry project.

ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/
@openzeppelin/=lib/openzeppelin-contracts/

and then your contract will deploy without problems

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.