When trying to generate user documentation and developer documentation from the NatSpec of a smart contract with solc --userdoc --devdoc MarketPlaceCustodial.sol by following the official documentation instructions

enter image description here

It couldn't find the file.

file not found

By providing the relative path :

solc --userdoc --devdoc ./src/custodial/MarketplaceCustodial.sol

It detected the file but returned the Error:

File not found. Searched the following locations: ""

This time not finding the path to the openzeppelin folder

openzeppelin path not found

All remappings are in place and working well with vscode and foundry, however solc doesn't seem to detect them.

How to do ?

1 Answer 1


Using those resources:

And trying different things I came up with this working solution:

solc --userdoc --devdoc @openzeppelin=[REPLACE_WITH_YOUR_ABSOLUTE_PATH]/lib/openzeppelin-contracts ./src/custodial/MarketplaceCustodial.sol

It works perfectly. I redirected it to .json file with > doc.json:

enter image description here

Note that I'm using Foundry, so if you're using Hardhat or Truffle you'll have to redirect the path to the /node_modules/ folder.

Your Answer

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

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