Verification with Libraries
Normally when a contract has linked libraries these are noted in the libraries
field in the metadata:
/partial_match/1/0x2fefbeF4d1445F523941c56349C2414cd5e9675d/metadata.json
"libraries": {
"ExchangeAdmins": "0x919551e7c778539f6238e3483358a2afbdaa83c9",
"ExchangeBlocks": "0xb01e1b1ee285c16429e750aca67546d5bcc797f3",
"ExchangeGenesis": "0xa2f3346c484ac1f55ef468fd2fe427b9730afb9f",
"ExchangeTokens": "0x432bcd4fade6e54f8b0773546af44bf7c90fa7f6",
"ExchangeWithdrawals": "0x4d6924ac10b840a17ac841b2e3d446c9e0d88d68"
},
These contract addresses for linked libraries need to be passed to the compiler for linking prior to the compilation, and should not be replaced directly in the bytecode. See the Warning in Solidity docs.
However some tools and frameworks do regex replace the placeholders in the bytecode. This causes the addresses not to be found in the metadata. In that case, Sourcify compares the onchain deployed bytecode with the compiled deployed bytecode (with placeholders) to extract the linked library addresses. This will be saved in a file called library-map.json
in the repository.
Check out these examples:
Starting from Solidity v0.5.0, the placeholders are of format __$<keccak256LibraryNameHash>$__
but before the format was __<LibraryName>__
.