In order to easy source code verification of complex contracts that are spread across several files, we need a standardized interface how to describe the relations between those files. In order to achieve that, the remapping feature was recently integrated into the compiler itself.
The next step is to define how the names of source files and the addresses of libraries are handed over to the compiler. The following json description format will serve both as input to the compiler and as output from it. It is used to uniquely determine the input that results in a certain bytecode for a single contract. If the compiler is invoked in a different way, not using this input (for example by using a file content retrieval callback), the compiler can still generate it alongside the bytecode of each contract.
This standard is versioned. Future versions are only required to provide the "version" field, the two keys inside the "compiler" field. The field compiler.keccak should be the keccak hash of a binary of the compiler with the given version.
The example below is presented in a human-readable way. Properly formatted complier inputs should use quotes correctly, reduce whitespace to a minimum and sort the keys of all objects to arrive at a unique formatting.
Comments are of course not permitted and used here only for explanatory purposes.
{
version: "1",
compiler: {
version: "soljson-2313-2016-12-12",
keccak: "0x123..."
},
sources:
{
"abc": "contract b{}",
"def": {keccak: "0x123..."}, // source has to be retrieved by its hash
"dir/file.sol": "contract a {}"
},
settings:
{
remappings: [":g/dir"],
optimizer: {enabled: true, runs: 500},
compilationTarget: "myFile.sol:MyContract",
// To be backwards compatible, use the full name of the contract in the output
// only if there are name clashes.
// If the full name was given as "compilationTargets", use the full name.
libraries: {
"def:MyLib": "0x123123..."
},
// The following will not be generated by the compiler and is only used
// as input to the compiler to restrict the fields it will output.
outputSelection: {
// to be defined
}
}
The output of the compiler is again json, the format of which still needs to be defined.
Retrieved from where?