使用Brownie编译合约后未生成JSON文件求助
Hey there, let's work through this issue where Brownie says it saved your build artifacts but you can't find the JSON files. Here are the most common fixes to try:
Double-check your project structure
Brownie expects Solidity contracts to live in the rootcontracts/directory of your project. Make sure your.solfiles are placed there, not in a subfolder (unless you've configured Brownie to look elsewhere viabrownie-config.yaml). Also confirm your files have the correct.solextension—no typos like.solidityor.sol.txt.Clean the build cache and recompile
Corrupted cache files can sometimes prevent artifacts from being generated properly. Run these commands in your project directory:brownie clean brownie compileAfter this, check the
build/contractsfolder again. The clean command wipes old build files, so a fresh compile should generate new artifacts if everything else is working.Check verbose compile output for hidden issues
The default compile message might not show warnings or subtle errors that are causing your contracts to skip compilation. Run the compile command with verbose mode to get more details:brownie compile -vLook for lines that mention skipped contracts, syntax errors, or version mismatches (like your contract's Solidity pragma not matching the version Brownie is using).
Verify your Brownie configuration
Open yourbrownie-config.yamlfile and check if there's abuild.pathsetting that overrides the default output directory. If this is set to a different path, your JSON files are probably there instead ofSimple_Storage/build/contracts.Check directory permissions
It's possible your user account doesn't have write permissions for thebuild/contractsdirectory. Try running Brownie with sudo (if on Linux/macOS) or run your terminal as an administrator (Windows) to rule out permission issues. Alternatively, manually create thebuild/contractsfolder and make sure it's writable.Inspect your contract code for silent issues
Even if Brownie says the project compiled, empty contracts or contracts with invalid syntax (that don't trigger a hard error) might not generate artifacts. Double-check your Solidity code:- Ensure you have a valid contract definition (not just empty lines or comments)
- Confirm your pragma statement matches a Solidity version Brownie supports
- Look for missing semicolons or other minor syntax mistakes that might be causing the compiler to ignore the contract
内容的提问来源于stack exchange,提问作者novice

