Solidity contract metadata
Vyper contracts don't support metadata.
Metadata
Since v0.4.7 (2016-12-15) Solidity compiler generates an output file called metadata that contains information about the contract and the compilation (see Solidity docs). This includes the compiler settings, contract ABI, NatSpec contract documentation, and used source files and their hashes. Sourcify takes full advantage of this information to exactly verify a deployed contract i.e. a byte-by-byte match of the contract.
To see metadata in action check out the Metadata Playground.
Check Matches to understand how Sourcify uses the metadata for verification
Where to find
Solidity compiler
You can pass the --metadata flag to the Solidity command line compiler to get the metadata output printed.
solc --metadata MyContract.sol
Write the metadata into a file with
solc --metadata MyContract.sol > metadata.json
Standard JSON Input-Output
To have the metadata in the ouput of the compilation with Solidity's standard JSON, add metadata to the outputSelection of the compilation input JSON. Below example outputs metadata for all contracts compiled.
"outputSelection": {
"*": {
"*": [
"metadata", // <--
"evm.bytecode",
"evm.bytecode.sourceMap"
],
...
},
...
}
Foundry
Foundry stores the contract compilation outputs to out/CONTRACT_NAME folder. The .json file contains the metadata of the contract under "rawMetadata" and "metadata" fields.
You can use the forge verify-contract command to verify a contract. See Foundry verification for more details.
Hardhat
Hardhat stores the outputs of the compilations under the artifacts/build-info/ folder inside the project. The .json files under the folder contain the Standard JSON Output of the Solidity compiler for all contracts. Hardhat outputs the metadata files of each contract by default under the JSON's output.contracts.<contract-path>.<contract-name>.metadata field.
You can use the native Hardhat verify plugin to verify your contracts. See Hardhat verification for more details.