Foundry invariant tests (stateful fuzzing) have helper functions for configurable invariant test setup such as targetArtifact(string memory newTargetedArtifact_), which adds a Target Artifact defined as:

The desired ABI to be used for a given contract. These can be used for proxy contract configurations.

In order to add this artifact, solidity must have generated this artifact or abi. What is an example of generating such an ABI?

1 Answer 1


To generate an ABI for a Solidity contract, you can use the Solidity compiler (solc) which can output the contract's ABI in JSON format.

For example, let's say you have a Solidity contract named MyContract defined in a file named MyContract.sol. You can generate the ABI for this contract using the following command in the terminal:

solc --abi MyContract.sol -o build

This command will generate the ABI in JSON format and save it in a file named MyContract.abi inside the build directory.

Once you have the ABI file, you can use it to interact with the contract using web3.js or other Ethereum development tools.

I hope this helps :)

  • Right, but how would I use this with targetArtifact? Mar 7, 2023 at 12:46

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.